Nitin Pawar

Nitin Pawar

  • 2k
  • 37
  • 738

Create a GET web API with endpoint

Mar 28 2020 9:37 AM
Hi ,
I am new Web Api learner, I have one below task can you help me which way easily to complete this task.
 
1. Create a GET web API with endpoint /<population | households>?state=<state_id,…>
 
Endpoint
- This API should return the value of Population or Households according to the path endpoint, for the states given in the comma-delimited query parameter state.
- Example /population?state=1,10,12 will return the population data for states 1, 10 and 12.
- Enable CORS for this endpoint.
 
Logic
- For the required states, look up Actuals table first. If the data is available, return that data. If not, return a sum of the value over all districts for the required state in the Estimates table.
- If any input state id is not available, return a 404 HTTP Code instead.
 
Response
- The response should be in JSON format like this:
 
[{ “State”: 1, “Population”: 22805514.45 }, { “State”: 10, “Population”: 338888364.12 }, ….]
 
Please can you provide me solution sample as well as reference link.
Thanks
Nitin

Answers (2)