3. API - adamgreenough/nicholas GitHub Wiki
Usage
All of your posts stored in Nicholas can be accessed with a simple read-only GET
API. A GET
API uses the URL to pass parameters. The first parameter is preceded with a question mark (?
) then contains the parameter name, an equals sign (=
) and then your option. Multiple parameters can be stringed together using an ampersand (&
). An example request might look like /api/feed/?page=2&perpage=10&tag=Cats
. You would access this by appending your request to your blog URL.
The API returns data in universal JSON format which can be parsed with a programming language of your choice.
/api/feed/
)
Feed (The API endpoint for a feed of your posts can be found at /api/feed/
. By default, this will return a JSON response of your latest POSTS_PER_PAGE
posts from all tags. It accepts the following GET
parameters.
Options
Paramater | Description | Type | Required? | Default |
---|---|---|---|---|
page |
Page offset | int |
false |
1 |
perpage |
Posts per page | int |
false |
POSTS_PER_PAGE (config) |
tag |
Posts by tag | string |
false |
null |
Examples
A request for page 2 of a feed with 10 posts per page for posts tagged 'Cats' would look like /api/feed/?page=2&perpage=10&tag=Cats
.
/api/single/
)
Single (The API endpoint for a single post can be found at /api/single/
. By default, this will return nothing. A slug
parameter is required to select the post you would like as a response.
Options
Paramater | Description | Type | Required? | Default |
---|---|---|---|---|
slug |
Post slug | string |
true |
null |
Examples
A request for page 2 of a feed with 10 posts per page for posts tagged 'Cats' would look like /api/feed/?page=2&perpage=10&tag=Cats
.