API - Pistos/diaspora GitHub Wiki
Generate API Key
Go to your user Settings page on your pod. At the bottom will be a link to generate an API key. Click it to generate the key. You can regenerate the key any time.
Usage
All API endpoints accept and return only JSON, and are at /fapi/v0
. For example, the /foobar
endpoint on diasp0ra.ca would be at https://diasp0ra.ca/fapi/v0/foobar.json
. Your API key is required as a parameter on every request. It can be provided in the GET parameters (e.g. /fapi/v0/some-endpoint.json?token=abcdef1234567890
), or in the POST data.
Why fapi
? F stands for fun, F stands for fake. I'm just putting this out there for us to play with until some experts make a real API, with OAuth, high security, standards support, and impressive-sounding things like that.
With curl
curl -d "text=test post sent at $(date)" 'https://diasp0ra.ca/fapi/v0/posts.json?token=6b2af2347ce324e822a396c77c72c215' -v
curl 'https://diasp0ra.ca/fapi/v0/posts.json?token=6b2af2347ce324e822a396c77c72c215' -d 'text=yo' -d 'aspect_ids[]=14' -d 'aspect_ids[]=13'
With rest-client CLI
% gem install rest-client
% restclient 'https://diasp0ra.ca/fapi/v0'
ree-1.8.7-2011.03 :001 > post '/posts.json', 'token' => '6b2af2347ce324e822a396c77c72c215', 'text' => "#test post\n\nSent at #{DateTime.now}"
With rest-client in Ruby
# gem install rest-client
require 'rest_client'
RestClient.post 'https://diasp0ra.ca/fapi/v0/posts.json', 'token' => '398959b90097bf61e33f064592cf27bc', 'text' => 'Test post.'
API Endpoints
GET /aspects
Returns your aspects.
GET /contacts
Returns your contacts, with embedded person objects.
GET /notifications
Returns up to 32 of your most recent unread notifications.
POST /posts
Posts a public message authored by you.
Parameters:
- text: The text of the post. May include newlines, and Markdown.
- aspect_ids (optional): An array of aspect ID numbers (integers). If omitted, the post will be public.
API Limits
- Requests are throttled: Requests cannot be made faster than once every 5 seconds.