Commit 038e9d21e7f085350d786cec80e3e8a6d4cbc2eb
Committed by
GitHub
1 parent
5f6968b4
Exists in
master
and in
5 other branches
Starting Documentation for API
added basic layout to follow on other methods and their endpoints, also added how to get OAuth permission, which is a simple request of access token once you have applications up and running.
Showing
1 changed file
with
34 additions
and
0 deletions
Show diff stats
README.md
@@ -80,6 +80,40 @@ Para Classes que envolvem formulários: | @@ -80,6 +80,40 @@ Para Classes que envolvem formulários: | ||
80 | * `CreateCourseForm` | 80 | * `CreateCourseForm` |
81 | * `UpdateCourseForm()` | 81 | * `UpdateCourseForm()` |
82 | 82 | ||
83 | + | ||
84 | +##API Description | ||
85 | +We are using mostly viewsets ( http://www.django-rest-framework.org/api-guide/viewsets/) to build our API endpoints now, so all default methods and API points were kept. | ||
86 | + | ||
87 | +* model list(GET) = list all objects from that mode in pagination mode, each page has 10 | ||
88 | +* model detail(GET) = give the details of the objects and most important fields of the ones objects its has relationships. | ||
89 | +* model create | ||
90 | + | ||
91 | +**Courses (URL: coursesapi)** | ||
92 | +* course list ("/coursesapi/") | ||
93 | +* course detail ("/coursesapi/id") (id is a parameter) | ||
94 | + | ||
95 | +**Subject (URL: subjectapi)** | ||
96 | +* subject list ("/subjectapi/") | ||
97 | +* subject detail ("/subjectapi/id") (id is a parameter) | ||
98 | + | ||
99 | +**Topic (URL: topicsapi)** | ||
100 | +* topics list ("/topicsapi/") | ||
101 | +* topic detail ("/topicsapi/id") (id is a parameter) | ||
102 | + | ||
103 | +**logs (URL: logs)** | ||
104 | +* logs list ("/logs/") | ||
105 | +* log detail ("/logs/id") (id is a parameter) | ||
106 | + | ||
107 | +#Obtaining an Access Token | ||
108 | +* First build an application o "amadeus/o/applications" following this tutorial: http://django-oauth-toolkit.readthedocs.io/en/latest/tutorial/tutorial_01.html#create-an-oauth2-client-application | ||
109 | + | ||
110 | +* Then request, using a valid user, an access token using the following template (you'll have to know how to translate a GET Method into a POST one) | ||
111 | +curl -X POST -d "grant_type=password&username=<user_name>&password=<password>" -u"<client_id>:<client_secret>" http://amadeus/o/token/ | ||
112 | + | ||
113 | +* finally, with your access token you can use test using | ||
114 | +curl -H "Authorization: Bearer <your_access_token>" -X POST -d"username=foo&password=bar" http://localhost:8000/users/ (inserting a new user) | ||
115 | + | ||
116 | + | ||
83 | ## Link's úteis | 117 | ## Link's úteis |
84 | [Git - Introdução e comandos básicos(PT-BR)](https://github.com/fernandomayer/git-rautu/blob/master/0_configuracao-inicial.md) | 118 | [Git - Introdução e comandos básicos(PT-BR)](https://github.com/fernandomayer/git-rautu/blob/master/0_configuracao-inicial.md) |
85 | 119 |