DEV Community

Discussion on: help creating django REST API

Collapse
 
alifarhad profile image
Farhad Ali • Edited

hi thanks for your reply.

the API#2 will be doing exactly the same thing as API#1. so for example if one of the API#1 endpoints says: /api/v1/users gets us a JSON like {name: jhon, age:1}

then

this API #2 would have exactly a mirror endpoint and it is supposed to return exactly the same data so in this case API#2 would be:
/api/v2/users ===> {name: jhon, age:1}

Collapse
 
hedgy134117 profile image
Graham Smith

Then what's the point of API2 if you get the same result from API1?

Thread Thread
 
tngeene profile image
Ted Ngeene

Also wondering the same.
Are you supposed to dump this data on the models of API#2?

Thread Thread
 
alifarhad profile image
Farhad Ali

hi friends, thanks for you reply.

I know it's pointless. but this is an academic activity. I don't see the point of doing such a practice, but I'm supposed to do it anyway, so could you tell me what's the best way to do this?

so far what I have planned is that create a regular django project, and create URLs that match with the API#1 endpoints, and connect those URLs to their views and then inside views just get data in JSON from API#1 and return the same JSON data back. and have little error handling thrown it.

so what do you think? does that sound good enough for this job? let me know if there's a better way to do this. API#1 also involves few POST requests and most of the endpoints use Auth/login as well.

Thread Thread
 
tngeene profile image
Ted Ngeene

Oh, that makes more sense now.
So, your approach is fine. The authentication part would be a bit tricky but you can pass the token as a parameter in your headers as you're posting to API#1. Then the response you get, you dump it to the db of API#2.