Smolar

NODES API

Smolar nodes API was created to make sychronization with our website https://www.smolar.pl/ much easier. Thanks to this, you can be always connected to our latest news without entering our website – API & automatic tasks will do the job.





API URL

https://api.smolar.pl/



REQUEST METHOD

POST



AUTHORIZATION

BEARER TOKEN*



AVAILABLE PUBLIC METHODS

  • getNode - method returning news – single or multiple
  • deletedNodes – method returning deleted news (in case of local db updates)



DATA PARAMS


getNode:

  • request_type: < single | multiple >
  • nid: < node_id > - only case single
  • timestamp: < 0 | timestamp_value > - only case multiple

Sample request objects: {"request_type":"multiple","timestamp": 0} {"request_type":"single","nid": 1740}


deletedNodes:

  • timestamp: < 0 | timestamp_value > - timestamp value bigger than 0 will return only nid's of deleted nodes since exact time

Sample request object: {"timestamp":1589736999}




SUCCESS RESPONSES


getNode:

  • HTTP Code 200
  • List of nodes and its content (case single will return only one node in array)

Sample response object: [{"node": { "id": "<node_id>", "title": "<node_title>", "short_title": "<node_short_description>", "content": "<node_description(content)>", "content_type": 0|1|2, (0-filtered html, 1-full html, 2-plain text) "square_image": { "filename": "<sq_img_filename>", "url": "<sq_image_url>", "width": <sq_image_width>, "height": <sq_image_height> }, "horizontal_image": { "filename": "<hr_img_filename>", "url": "<hr_img_url>", "width": <hr_img_width>, "height": <hr_img_height> }, "vertical_image": { "filename": "<vr_img_filename>", "url": "<vr_img_url>", "width": <vr_img_width>, "height": <vr_img_height> }, "content_image": { "filename": "<content_img_filename>", "url": "<content_img_url>", "width": <content_img_width>, "height": <content_img_height> }, "attachments": [ { "filename": "<attachment_filename>", "url": "<attachment_url>", "description": "<attachment_title>" } ], "created": <created_timestamp>, "changed": <changed_timestamp> }}]


deletedNodes:

  • HTTP Code 200
  • List of nid's (node_id's) of deleted nodes since time specified in request

Sample response object: [{"nid": 1759},{"nid": 1760},{"nid": 1761}]




ERROR RESPONSES


In error case API will response error HTTP code and error object containing error code and error short description
  • HTTP Code 4xx/5xx
  • Response error object with error code & description params

Sample response object: Code 401 UNAUTHORIZED { "errorMessage": "wrong bearer token", "errorCode": "3" }
List of all API responses in table below.
HTTP Response Code Message Error Code Reason/Action info
200 [nodes_array] or [deleted_nodes_id_array] n/a Request received correctly, matching nodes were returned
406 key values empty 1 One or more key values (eg. request_type) is missing
406 wrong request type 2 Request type is incorrect
406 wrong timestamp 2 Timestamp is not a correct value
401 wrong bearer token 3 Authorization token is wrong
400 no request 4 No request sent
400 no post 5 POST array not found
404 node not found 6 Node with requested ID was not found or is not available



SAMPLE CALLS

Feel free to copy it into app like Postman and get the automatically generated code for every language you prefer :)
getNode - multiple curl --location --request POST 'https://api.smolar.pl/getNode/' \ --header 'Authorization: Bearer <YOUR_API_BEARER_TOKEN>' \ --header 'Content-Type: application/json' \ --data-raw '{ "request_type":"multiple", "timestamp": 0 }' *Max number of returned nodes is 250 - sorted by creation date descending getNode - single curl --location --request POST 'https://api.smolar.pl/getNode/' \ --header 'Authorization: Bearer <YOUR_API_BEARER_TOKEN>' \ --header 'Content-Type: application/json' \ --data-raw '{ "request_type":"single", "nid": <NODE_ID> }' deletedNodes curl --location --request POST 'https://api.smolar.pl/deletedNodes/' \ --header 'Authorization: Bearer <YOUR_API_BEARER_TOKEN>' \ --header 'Content-Type: application/json' \ --data-raw '{ "timestamp":<YOUR_TIMESTAMP_VALUE> }'


*NOTES

To receive an API token – please contact us via email, with short explanation of your purpose for our API usage.