Skip to content

Commit

Permalink
Initial commit of the DN API docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kellysutton committed Feb 11, 2014
0 parents commit d90d2d6
Show file tree
Hide file tree
Showing 13 changed files with 164 additions and 0 deletions.
2 changes: 2 additions & 0 deletions 01_Introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## Introduction
The Designer News API provides a simple HTTP based REST based mechanism for interacting with LayerVault and allowing applications to access user information via oAuth 2 authenticated requests, over SSL. API responses are simple JSON objects.
6 changes: 6 additions & 0 deletions 02_Getting_Started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## Getting Started

0. Please send an email to news@layervault.com to request your API credentials. Please include your callback URL. One day, this might be automated.
0. Receive a friendly note back from the LayerVault staff with your application credentials.
0. Note your ```client_id``` and ```client_secret```.
0. Try the example Access Token request below.
2 changes: 2 additions & 0 deletions 03_API_Endpoint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
### API Endpoint
https://news.layervault.com/api/v1
11 changes: 11 additions & 0 deletions 04_Summary_of_Resource_URL_Patterns.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
### Summary of Resource URL Patterns

/api/v1/me
/api/v1/stories/recent
/api/v1/stories/search
/api/v1/stories/:id/upvote
/api/v1/stories
/api/v1/stories/:id
/api/v1/comments/:id/upvote(.:format
/api/v1/comments/:id/reply
/api/v1/comments/:id
3 changes: 3 additions & 0 deletions 05_URL_Parameters.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### URL Parameters
:id - The ID of the resource
:page - The page of the resources
22 changes: 22 additions & 0 deletions 06_Authentication_and_Requesting_Access_Tokens.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## Authentication and Requesting Access Tokens

All API requests are required to be authenticated via an oAuth 2 access token. It's easy to request a token via the command line to get a feel for how things work:

```shell
curl -i https://api.news.layervault.com/oauth/token \
-F grant_type="password" \
-F username="<your Designer News username>" \
-F password="<your Designre News password>" \
-F client_id="<client_id_goes_here>" \
-F client_secret="<client_secret_goes_here>"
```

Which will return an Access token response like this one:

```json
{
"access_token":"aec9c670cf5e673bfedf83d055d2a2e0e5f37e52d3b41cffcf7874f73a7458bf",
"token_type":"bearer",
"scope":"user"
}
```
5 changes: 5 additions & 0 deletions 07_Configuring_a_Web_Application.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### Configuring A Web Application as a LayerVault API client

First of all, make sure that your redirect URI is correctly specified.

Then, when configuring your oAuth 2 client library, tell it to use ```https://api.news.layervault.com/oauth/authorize``` to request authorization and ```https://api.news.layervault.com/oauth/token``` to get access tokens. Most libraries will default to this convention anyway.
7 changes: 7 additions & 0 deletions 08_Making_API_Calls.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Making API Calls

Once you have your access token, making some API calls from the command line is also easy:

```shell
curl -H 'Authorization: Bearer <your access token>' 'https://api.news.layervault.com/api/v1/me'
```
3 changes: 3 additions & 0 deletions 09_Versioning.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Versioning

Currently, the LayerVault API is versioned with a URL segment, such as ```/v1/```. The current production version of the API is Version 1, so your calls should use ```/v1/``` as the version segment.
8 changes: 8 additions & 0 deletions 10_Rate_Limits.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## Rate Limits

The API currently limits the requests you can make against it hourly. We have provided two response headers with each request to the API with Rate Limiting Information. They are returned from every API call.

X-RateLimit-Limit: 300
X-RateLimit-Remaining: 299

`X-RateLimit-Limit` is your current limit per hour. `X-RateLimit-Remaining` is how many requests you have left. If you need more requests than 300/hr, please [contact us](mailto:support@layervault.com) and we'll do our best to accommodate you.
27 changes: 27 additions & 0 deletions 11_Users.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
### User Information

#### Retrieving User Information

This call returns the user information for which the Client is acting on behalf of.

Definition

GET /api/v1/me

Example Request

$ curl -H 'Authorization: Bearer <your access token>' 'https://api.news.layervault.com/api/v1/me'

Example Response

```json
{
"me": {
"created_at": "2012-11-15T04:48:45Z",
"first_name": "Kelly",
"job": "Founder at LayerVault",
"last_name": "Sutton",
"portrait_url": "https://news.layervault.com/cats.gif"
}
}
```
66 changes: 66 additions & 0 deletions 12_Stories.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
### Stories

#### Retrieving Story Information

This call returns information for a story.

Definition

GET /api/v1/stories/:id

Example Request

$ curl -H 'Authorization: Bearer <your access token>' 'https://api.news.layervault.com/api/v1/stories/:id'

Example Response

```json
{
"story": {
"comment": "",
"comments": [
...
],
"created_at": "2014-01-24T17:15:19Z",
"id": 13627,
"site_url": "http://localhost:3000/stories/13627-a-logo-should-tell-a-story",
"title": "A logo should tell a story.",
"url": "http://localhost:3000/click/stories/13627",
"vote_count": 11
}
}
```

#### Retrieving the front page

This call will returns a list of stories on the set page. **Note:** Page numbering starts at `1`.
If not specified, the default page will be `1`.

Definition

GET /api/v1/stories

Example Request

$ curl -H 'Authorization: Bearer <your access token>' 'https://api.news.layervault.com/api/v1/stories'

Example Response

```json
{
"stories": [
{
"comment": "",
"comments": [
...
],
"created_at": "2014-01-24T17:15:19Z",
"id": 13627,
"site_url": "http://localhost:3000/stories/13627-a-logo-should-tell-a-story",
"title": "A logo should tell a story.",
"url": "http://localhost:3000/click/stories/13627",
"vote_count": 11
}
]
}
```
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## Please see each individual chapter file.

0 comments on commit d90d2d6

Please sign in to comment.