API Requests

Schema

The API is accessable only over HTTPS. All data is sent and received in JSON format.

curl -i https://api.convertiser.com/publisher/websites/ 
     -H "Authorization: Token your-personal-secret-token-here"

HTTP/1.1 200 OK
Server: nginx/1.4.6 (Ubuntu)
Date: Fri, 17 Nov 2017 13:15:25 GMT
Content-Type: application/json
Content-Length: 18584
Connection: keep-alive
Content-Language: en
Vary: Accept-Language
Allow: GET, HEAD, OPTIONS
X-Frame-Options: SAMEORIGIN
Strict-Transport-Security: max-age=31536000
Important

For requests, resource URL should be ended with slash /, otherwise redirect response returned.

curl -i -X GET https://api.convertiser.com/publisher/websites 
        -H "Authorization: Token your-personal-secret-token-here"

HTTP/1.1 301 Moved Permanently

Blank fields are included as null instead of being omitted.

HTTP Verbs

The API strives to use appropriate HTTP verbs for each action.

Verb Description
HEAD Can be issued against any resource to get just the HTTP header info.
GET Used for retrieving resources.
POST Used for creating resources.
PATCH Used for updating resources with partial JSON data.
PUT Used for replacing resources or collections.
DELETE Used for deleting resources.
OPTIONS Used for gettings resource description.

Parameters

Many API methods take optional parameters, example for filtering or ordering data.

For GET requests, any parameters not specified as a segment in the path can be passed as an HTTP query string parameter:

curl -X GET https://api.convertiser.com/publisher/websites/?ordering=-created_at&status=approved 
     -H "Authorization: Token your-personal-secret-token-here"

For POST, PATCH, PUT, and DELETE requests, parameters (usually) not included in the URL should be encoded as JSON :

curl -X POST https://api.convertiser.com/publisher/websites/
     -H "Authorization: Token your-personal-secret-token-here"
     -H "Content-Type: application/json"
     -d '{"title": "website-title"}'