-
Notifications
You must be signed in to change notification settings - Fork 0
Cameron Marlow edited this page Feb 12, 2015
·
13 revisions
The data model is specified in urlz.model and the API methods are specified in urlz.sites.api.
The package used, Flask-Restless handles translating the model into an API. Here are a few queries to show how to use the API.
HOST=urler.herokuapp.com
curl \
-X POST \
-H "Content-type: application/json" \
-d '{"username": "meandmybadself","name": "Jeffery","email": "meandmybadself@gmail.com","password": "yoyoyoyo"}' \
https://$HOST/api/userAfter you get the auth token, you'll need to send it up as the header Authentication-Token as seen in the next few examples.
curl \
-X POST \
-H "Content-type: application/json" \
-d '{"username":"meandmybadself","password":"yoyoyoyo"}' \
https://$HOST/api/login
AUTH_TOKEN={response}curl \
-H "Content-type: application/json" \
-H "Authentication-Token: $AUTH_TOKEN" \
https://$HOST/api/user/meandmybadselfcurl \
-X PATCH \
-H "Content-type: application/json" \
-H "Authentication-Token: $AUTH_TOKEN" \
-d '{"tags": {"add": {"name": "stuff", "type": "user", "description": "Love this stuff"}}}' \
https://$HOST/api/user/meandmybadselfIf you try to post the URL and it is already there, you'll get the message "IntegrityError". I will work on making this clearer.
curl \
-X POST \
-H "Content-type: application/json" \
-H "Authentication-Token: $AUTH_TOKEN" \
-d '{"url": "http://boingboing.net/2015/01/20/why-animals-eat-psychoactive-p.html"}' \
https://$HOST/api/urlcurl \
-G \
-H "Content-type: application/json" \
-H "Authentication-Token: $AUTH_TOKEN" \
-d 'q={"filters":[{"name":"url","op":"eq","val":"http://boingboing.net/2015/01/20/why-animals-eat-psychoactive-p.html"}]}' \
https://$HOST/api/urlcurl \
-X POST \
-H "Content-type: application/json" \
-H "Authentication-Token: $AUTH_TOKEN" \
-d '{"canonical_url": "dbd82a53-556b-4f12-a8b3-2ba25ddaed8f","note": "So much style","tags": [{"id": "943f5608-f23d-4c79-9359-8b28872247ca"}]}' \
https://$HOST/api/post