-
Notifications
You must be signed in to change notification settings - Fork 120
API
Authentication can be setup to use token auth. This is located in the config-default.py
file:
# Token Auth Setup
REQUIRE_AUTH = False
AUTH_TOKEN = 'your_token_here_and_what_not'
If REQUIRE_AUTH
is set to True, all requests to Sketchy will require the token specified.
You can send the token with the following header for each request:
Token: your_token_here_and_what_not
Or you can send the token as a GET parameter for each request: GET /api/v1.0/capture?token=my_secret_is_here
Here is an example with Token auth using the Token header:
POST /api/v1.0/capture HTTP/1.1
Host: 127.0.0.1:5000
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: application/json
Token: this_is_my_super_secret_token
Connection: keep-alive
Content-Length: 32
{"url": "https://google.com"}
Here is an example with Token auth using the token GET parameter:
GET /api/v1.0/capture?token=super_secret HTTP/1.1
Host: 127.0.0.1:5000
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: application/json
Connection: keep-alive
Note: To ensure the token is not logged in access.log, it is strongly encouraged to use the token header as opposed to the token GET parameter.
To use the API, you must set your content-type to application/json.
Content-Type: application/json
API Calls
HTTP Method | URI | ACTION |
---|---|---|
GET | http://[hostname]/api/v1.0/capture | Retrieve a list of captures |
GET | http://[hostname]/api/v1.0/capture/last | Retrieve the last capture |
GET | http://[hostname]/api/v1.0/capture/[id] | Retrieve a specific capture |
POST | http://[hostname]/api/v1.0/capture | Create a new capture |
Create a new capture only
POST Request
{
"url": "https://google.com"
}
POST Response
HTTP/1.0 201 CREATED
Content-Type: application/json
Content-Length: 266
Server: Werkzeug/0.9.4 Python/2.7.5
Date: Wed, 14 May 2014 16:03:33 GMT
{
"job_status": "CREATED",
"capture_status": null,
"created_at": "2014-05-14 09:03:33.497800",
"html_url": null,
"id": 1,
"modified_at": "None",
"scrape_url": null,
"sketch_url": null,
"url": "https://google.com",
"url_response_code": null
}
Check URL status code only
POST Request
{
"url": "https://google.com",
"status_only": true
}
POST Response
HTTP/1.0 201 CREATED
Content-Type: application/json
Content-Length: 266
Server: Werkzeug/0.9.4 Python/2.7.5
Date: Wed, 14 May 2014 16:03:33 GMT
{
"job_status": "CREATED",
"capture_status": null,
"created_at": "2014-05-14 09:03:33.497800",
"html_url": null,
"id": 1,
"modified_at": "None",
"scrape_url": null,
"sketch_url": null,
"url": "https://google.com",
"url_response_code": null
}
Create capture and specify a callback
POST Request
{
"url": "https://google.com",
"callback": "https://scumblr.mysite.com/callback"
}
POST Response
HTTP/1.0 201 CREATED
Content-Type: application/json
Content-Length: 288
Server: Werkzeug/0.9.4 Python/2.7.5
Date: Wed, 14 May 2014 16:03:33 GMT
{
"job_status": "CREATED",
"callback": "https://scumblr.mysite.com/callback",
"capture_status": null,
"created_at": "2014-05-14 09:03:33.497800",
"html_url": null,
"id": 1,
"modified_at": "None",
"scrape_url": null,
"sketch_url": null,
"url": "https://google.com",
"url_response_code": null
}
###Static API Calls###
To use the API, you must send a multipart upload. For the filename you are capturing the name of the field must be name
. The filename field must be set to a filename that ends in .html. If you are using callback, the name of the callback field must be callback
. See examples below:
API Calls
HTTP Method | URI | ACTION |
---|---|---|
GET | http://[hostname]/api/v1.0/static | Retrieve a list of static captures |
GET | http://[hostname]/api/v1.0/capture/last | Retrieve the last static capture |
GET | http://[hostname]/api/v1.0/capture/[id] | Retrieve a specific static capture |
POST | http://[hostname]/api/v1.0/capture | Create a new static capture |
Screenshot and scrape a provided HTML file POST Request
...truncated
Content-Type: multipart/form-data; boundary=---------------------------9051914041544843365972754266
Content-Length: 420
-----------------------------9051914041544843365972754266
Content-Disposition: form-data; name="file"; filename="mytestsite.html"
Content-Type: text/html
<html>
<h1>test HTML file for static capture</h1>
</html>
-----------------------------9051914041544843365972754266
Post response
{
"capture_status": null,
"created_at": "2014-12-04 09:54:23.904301",
"filename": "0fa51431-c189-461c-9913-86ca265743be-mytestsite.html",
"html_url": null,
"id": 35,
"job_status": "CREATED",
"modified_at": "None",
"retry": null,
"scrape_url": null,
"sketch_url": null
}
Create static capture and specify a callback
POST Request
...truncated
Content-Type: multipart/form-data; boundary=---------------------------9051914041544843365972754266
Content-Length: 420
-----------------------------9051914041544843365972754266
Content-Disposition: form-data; name="file"; filename="mytestsite.html"
Content-Type: text/html
<html>
<h1>test HTML file for static capture</h1>
</html>
-----------------------------9051914041544843365972754266
Content-Disposition: form-data; name="callback";
http://www.netflix.com
-----------------------------9051914041544843365972754266--
Post Response
{
"callback": "http://www.netflix.com",
"capture_status": null,
"created_at": "2014-12-04 09:54:23.904301",
"filename": "0fa51431-c189-461c-9913-86ca265743be-mytestsite.html",
"html_url": null,
"id": 35,
"job_status": "CREATED",
"modified_at": "None",
"retry": null,
"scrape_url": null,
"sketch_url": null
}