Changes

Jump to navigation Jump to search
Line 17: Line 17:       −
== Progress ==
+
== REST API v1 Resources ==
<br />
     −
At the moment , I am aiming to get a basic set of features that a Social site like this should offer.So the first phase deals with developing a minimal functional site that offers basic set of social networking features and Project sharing capabilities.
+
==== User Creation ====
 +
{| class="wikitable"
 +
|-
 +
! Resource !! Description
 +
|-
 +
| POST /api/v1/register/  ||  Makes http POST request with the JSON data to create a new user in the database ,if a user already exist raises HTTP 400 badrequest and returns a Json response  with error message "the  username already exist" . Returns HTTP 201 for successfully Created User
 +
|-
 +
| Example || curl --dump-header - -H "Content-Type:application/json" -X POST --data '{"username" :"user101" , "email" :"user@mail.com" , "password" : "password" }'  http://moksaya-rahulgaur.rhcloud.com/api/v1/register/
 +
|-
 +
| Response ||  HTTP/1.1 201 CREATED Date: Thu, 19 Sep 2013 23:49:52 GMT Server: Apache/2.2.15 (Red Hat) Vary: Accept,Accept-Language,Cookie X-Frame-Options: SAMEORIGIN Content-Language: en-us Location:http://moksaya-rahulgaur.rhcloud.com/api/v1/register/19/
 +
Content-Length: 0
 +
Content-Type: text/html; charset=utf-8
 +
|}
 +
 
 +
==== Authentication and User Login ====
 +
 
 +
Requires Username and Password for obtaining the api_keys , and rest of the other resources are accessed with the API Keys.
 +
There are two ways to do it, these are Publicly accessible end points.
 +
 
 +
{| class="wikitable"
 +
|-
 +
! Resource  !! Description
 +
|-
 +
| GET /api/v1/token/auth/  ||  Returns the apikey for the requested user, we need to supply the username and password in the request headers .
 +
|-
 +
| Example || curl -k --user "aregee:notebook" http://moksaya-rahulgaur.rhcloud.com/api/v1/token/auth/
 +
|-
 +
| Response || {
 +
    "key": "531ffb6152171df4f60b1b09f09dd1b4c5aba997"
 +
}
 +
 
 +
|-
 +
| POST /api/v1/user/login/  || Another way is to POST the user credentials as a JSON data to this end point and returns User Resource with the API_key . Raises HTTP 401 for unauthorized with error response
 +
|-
 +
| Example ||  curl --dump-header - -H "Content-Type:application/json" -X POST --data '{"username":"user101","password":"notebook" }' http://moksaya-rahulgaur.rhcloud.com/api/v1/user/login/
 +
|-
 +
| Response || HTTP/1.1 200 OK
 +
Date: Fri, 20 Sep 2013 22:16:20 GMT
 +
Server: Apache/2.2.15 (Red Hat)
 +
Vary: Accept,Accept-Language,Cookie,Accept-Encoding
 +
X-Frame-Options: SAMEORIGIN
 +
Content-Language: en-us
 +
Content-Type: application/json
 +
Set-Cookie: sessionid=ddb4289b9fe8b2a963bfc540f81559c3; expires=Fri, 04-Oct-2013 22:16:20 GMT; httponly; Max-Age=1209600; Path=/
 +
Transfer-Encoding: chunked
 +
 
 +
{
 +
    "apikey": "03f9a40ddd029b0a773a54f189aaa92d5a07c2d2",
 +
    "email": "user@mail.com",
 +
    "first_name": "",
 +
    "id": 14,
 +
    "last_name": "",
 +
    "resource_uri": "/api/v1/user/14/",
 +
    "username": "user101"
 +
}
 +
 
 +
|}
 +
 
 +
==== User Resource ====
 +
Authenticated users can access the User Resource , with the api_key and User Resource supports following authenticated  options
 +
 
 +
{| class="wikitable"
 +
|-
 +
! Resource !! Description
 +
|-
 +
| GET /api/v1/user/ || Returns the list of all user accounts when accessed with authenticated header but returns requested user's resource when username and api_key supplied in url parameters
 +
|-
 +
| Example ||  curl --dump-header - -H "Content-Type: application/json" -X GET http://moksaya-rahulgaur.rhcloud.com/api/v1/user/?username=akshit\&api_key=feea1175cdb9dde076eb68b5d83857fe2a58a186
 +
|-
 +
| Response || HTTP/1.1 200 OK
 +
Date: Fri, 20 Sep 2013 22:32:23 GMT
 +
Server: Apache/2.2.15 (Red Hat)
 +
Vary: Accept,Accept-Language,Cookie,Accept-Encoding
 +
X-Frame-Options: SAMEORIGIN
 +
Content-Language: en-us
 +
Cache-Control: no-cache
 +
Content-Type: application/json
 +
Transfer-Encoding: chunked
 +
 
 +
{
 +
    "meta": {
 +
        "limit": 20,
 +
        "next": null,
 +
        "offset": 0,
 +
        "previous": null,
 +
        "total_count": 1
 +
    },
 +
    "objects": [
 +
        {
 +
            "apikey": "feea1175cdb9dde076eb68b5d83857fe2a58a186",
 +
            "email": "user@mail.com",
 +
            "first_name": "",
 +
            "id": 19,
 +
            "last_name": "",
 +
            "resource_uri": "/api/v1/user/19/",
 +
            "username": "akshit"
 +
        }
 +
    ]
 +
}
 +
|-
 +
| GET /api/v1/user/<username>/  || We can also access users with their respective usernames and returns HTTP 401 for resource not found
 +
|-
 +
| Example || curl --dump-header - -H "Content-Type: application/json" -X GET http://moksaya-rahulgaur.rhcloud.com/api/v1/user/aregee/?username=spock\&api_key=d2fe32b15b0b395a5d0e0ea4b7eb1e5d6ea15de7
 +
|-
 +
| Response || HTTP/1.1 200 OK
 +
Date: Fri, 20 Sep 2013 23:05:43 GMT
 +
Server: Apache/2.2.15 (Red Hat)
 +
Vary: Accept,Accept-Language,Cookie,Accept-Encoding
 +
X-Frame-Options: SAMEORIGIN
 +
Content-Language: en-us
 +
Cache-Control: no-cache
 +
Content-Type: application/json
 +
Transfer-Encoding: chunked
 +
 
 +
{
 +
    "apikey": "531ffb6152171df4f60b1b09f09dd1b4c5aba997",
 +
    "email": "iamaregee@gmail.com",
 +
    "first_name": "",
 +
    "id": 2,
 +
    "last_name": "",
 +
    "resource_uri": "/api/v1/user/2/",
 +
    "username": "aregee"
 +
}
 +
|-
 +
| DELETE /api/v1/user/<username>/ || Removes the requested <username> from the database .
 +
|-
 +
| Example ||  curl --dump-header - -H "Content-Type: application/json" -X DELETE  http://moksaya-rahulgaur.rhcloud.com/api/v1/user/akshit/?username=akshit\&api_key=feea1175cdb9dde076eb68b5d83857fe2a58a186
 +
|-
 +
| Response || HTTP/1.1 204 NO CONTENT
 +
Date: Fri, 20 Sep 2013 22:36:22 GMT
 +
Server: Apache/2.2.15 (Red Hat)
 +
Vary: Accept,Accept-Language,Cookie
 +
X-Frame-Options: SAMEORIGIN
 +
Content-Language: en-us
 +
Content-Length: 0
 +
Content-Type: text/html; charset=utf-8
 +
 
 +
|}
 +
 
 +
 
 +
==== Profile Resource ====
 +
 
 +
{| class="wikitable"
 +
|-
 +
! Resource !! Description
 +
|-
 +
| POST /api/v1/profile/ || Making http post to this end  point with the json data containing the Profile fields creates a new user profile , which is Related to all the other resources.Returns HTTP 201 response for successfully created user profile , returns HTTP 400 bad request with error response for unsuccessful attempts. 
 +
|-
 +
| Example || curl --dump-header - -H "Content-Type:application/json" -X POST --data '{"user":"/api/v1/user/akshit/" , "about_me" :"Profile Create with CURL"}'  http://moksaya-rahulgaur.rhcloud.com/api/v1/profile/?username=akshit\&api_key=feea1175cdb9dde076eb68b5d83857fe2a58a186
 +
|-
 +
| GET /api/v1/profile/ || Returns list of all user profiles , throttles twenty results per request.
 +
|-
 +
| GET /api/v1/profile/username/ || Returns ProfileResource for the requested user , returns http 404 if resource is not found.
 +
|-
 +
| Example || curl --dump-header - -H "Content-Type:application/json" -X GET http://moksaya-rahulgaur.rhcloud.com/api/v1/profile/akshit/?username=akshit\&api_key=feea1175cdb9dde076eb68b5d83857fe2a58a186
 +
|-
 +
| Respone || HTTP/1.1 200 OK
 +
Date: Thu, 19 Sep 2013 23:56:13 GMT
 +
Server: Apache/2.2.15 (Red Hat)
 +
Vary: Accept,Accept-Language,Cookie,Accept-Encoding
 +
X-Frame-Options: SAMEORIGIN
 +
Content-Language: en-us
 +
Cache-Control: no-cache
 +
Content-Length: 279
 +
Content-Type: application/json
 +
 
 +
{
 +
    "about_me": "Profile Create with CURL",
 +
    "followers": [],
 +
    "following": [],
 +
    "id": 19,
 +
    "language": "en",
 +
    "location": "",
 +
    "mugshot": null,
 +
    "privacy": "registered",
 +
    "projects": [],
 +
    "resource_uri": "/api/v1/profile/19/",
 +
    "user": "akshit"
 +
}
 +
|-
 +
| PUT /api/v1/profile/<username>/  || Updates the Profile Resource field with the supplied JSON data.Currently works with only about_me field but can be extended to include location and mugshot or Avatar fields
 +
|-
 +
| Example || curl --dump-header - -H "Content-Type:application/json" -X PUT --data '{"about_me" :"Profile Create & updated with  CURL "}'  http://moksaya-rahulgaur.rhcloud.com/api/v1/profile/akshit/?username=akshit\&api_key=feea1175cdb9dde076eb68b5d83857fe2a58a186
 +
|-
 +
|}
 +
 
 +
 
 +
==== Project Resource ====
 +
 
 +
{| class="wikitable"
 +
|-
 +
! Resource  !!  Description
 +
|-
 +
| GET /api/v1/projects/ || Following query returns the list of all the projects submitted by the user.
 +
|-
 +
| GET /api/v1/projects/<id>/ || We can query a particular project with its id. This would return ProjectResource for the requested project id.It also shows related comments and likes on the project.
 +
|-
 +
| Example || curl --dump-header - -H "Content-Type: application/json" -X GET http://moksaya-rahulgaur.rhcloud.com/api/v1/projects/1/?username=spock\&api_key=d2fe32b15b0b395a5d0e0ea4b7eb1e5d6ea15de7
 
   
 
   
 +
|-
 +
 +
| Response  || HTTP/1.1 200 OK
 +
Date: Fri, 20 Sep 2013 23:40:38 GMT
 +
Server: Apache/2.2.15 (Red Hat)
 +
Vary: Accept,Accept-Language,Cookie,Accept-Encoding
 +
X-Frame-Options: SAMEORIGIN
 +
Content-Language: en-us
 +
Cache-Control: no-cache
 +
Content-Type: application/json
 +
Transfer-Encoding: chunked
 +
 +
{
 +
    "Likes": 6,
 +
    "comment": [
 +
        {
 +
            "entry": "This is My Project",
 +
            "resource_uri": "/api/v1/comment/3/",
 +
            "text": "This is a Comment :)",
 +
            "user": "aregee"
 +
        },
 +
        {
 +
            "entry": "This is My Project",
 +
            "resource_uri": "/api/v1/comment/8/",
 +
            "text": "Lets Post another Comment here :D",
 +
            "user": "aregee"
 +
        },
 +
        {
 +
            "entry": "This is My Project",
 +
            "resource_uri": "/api/v1/comment/9/",
 +
            "text": "But This Kinda Looks Sweet :D",
 +
            "user": "aregee"
 +
        },
 +
        {
 +
            "entry": "This is My Project",
 +
            "resource_uri": "/api/v1/comment/29/",
 +
            "text": "superb :)",
 +
            "user": "nikking1793"
 +
        },
 +
        {
 +
            "entry": "This is My Project",
 +
            "resource_uri": "/api/v1/comment/30/",
 +
            "text": "superb :)",
 +
            "user": "nikking1793"
 +
        }
 +
    ],
 +
    "desc": "Hello Project world",
 +
    "history": "",
 +
    "id": 1,
 +
    "resource_uri": "/api/v1/projects/1/",
 +
    "screenshot": "/media/projects/lin.jpg",
 +
    "shared_date": "2013-09-17T16:44:53.773919",
 +
    "src": "/media/projects/try.py",
 +
    "title": "This is My Project",
 +
    "user": "aregee"
 +
}
 +
 +
|-
 +
| POST /api/v1/projects/ || Making an http POST request to this URI with the Multipart form data in the JSON format creates a new project and Returns HTTP 201 for successfully created  projects
 +
|-
 +
| Example ||  curl -F "user=/api/v1/profile/2/" -F "title=Fiddle with JS" -F "desc=this file documents my PROGRESS with learning JavaScript" -F "src=@projects/objects.js" -F "screenshot=@projects/img_screen.png" http://127.0.0.1:8000/api/v1/projects/?username=aregee\&api_key=531ffb6152171df4f60b1b09f09dd1b4c5aba99
 +
|-
 +
| PATCH /api/v1/projects/<id>/  || Updates the changed field to an existing project in the form of json data.
 +
|-
 +
| Example || curl --dump-header - -H "Content-Type:application/json" -X PATCH --data '{"title":"Gallery Lock ++ " }' http://127.0.0.1:8000/api/v1/projects/1/?username=aregee\&api_key=531ffb6152171df4f60b1b09f09dd1b4c5aba99
 +
|-
 +
| PUT /api/v1/projects/<id>/  || We can also use the HTTP PUT request to update all the fields of an existing project
 +
|-
 +
| DELETE /api/v1/projects/<id>/ || Destroys the current project and the resource related to it : Likes , Comments 
 +
|-
 +
|}
 +
 +
    
==== UI/UX ====
 
==== UI/UX ====
25

edits

Navigation menu