API
Introduction
ToWatchList uses a basic REST API to allow for both sending and retrieving data from the server. HTTPS is recommended for all API queries for user security. The content type of all responses is 'application/json' and the data is formatted as JSON array of key/value pairs.
Getting a User's API Key
To use the public ToWatchList API, an application should convert the user's login email and password to an API key:
A matching username & password will return status code 200 with the hashed key within a JSON object like this:
Incorrect username & password combinations return status code 401 and:
Once the API key is obtained, it is suggested that the username and password be purged for enhanced user security. Users can reset their API key from the tools page at any time if it is leaked or abused.
Scanning URLs for Videos
To tell ToWatchList to scan a page for embedded videos, an application or script can submit a GET request to the URL scanner with this syntax:
Where the [URL] must be encoded with the JavaScript encodeURIComponent() function, and the [API Key] is the value returned from the function above. For example, if an app wanted to tell ToWatchList to scan http://thesite.com/page.php the query would look like this:
The response will have status code 200 and be a JSON encoded array of keys and values like these examples:
The result value indicates how the request was processed and the info key gives a short, human-readable statement about the result. Above, the result value of 1 is considered a successful scan. However, if things worked successfully but no videos were found, the API returns HTTP status code 200 and result code 2:
If an invalid API key is passed (perhaps because it was reset), the result code will be 3 with status code 401:
Finally, other errors, such as if the passed URL does not resolve, will generate a result code of 4 with status code 400:
Questions
Did you find this useful? Do you have questions, concerns, or suggestions about the API? Please don't hesitate to contact me.