How to check user is within given Country or not using reverse geocode. "HereMap Reverse Geocode" - reverse-geocoding

I want to get reverse geocode of Here map to fetch user postalCode with specified Country. So, if user is not in that Country, it should give error/warning message.

How about enabling the parameter show->countryInfo on the request so that we receive the country info in the response, and then do your own client-side checking for that country? https://developer.here.com/documentation/geocoding-search-api/api-reference-swagger.html

Related

Public and up-to-date API for getting country, state, city

I need an API for getting country, state, city.
I need to get by following endpoints
/somepath - for countries
/:countryName - for states
/:stateName - for cities.
If you know any up to date API for this task, please write a comment about it.
Thanks

SoundCloud API - genres and filter parameter of /tracks endpoint

I am using the SoundCloud API for a web application.
With the /tracks endpoint, I have two troubles below.
1. When I send a request with an invalid genres parameters, does the /tracks endpoint return 503 (Service Unavailable)?
When I intentionally use a condition which will not match any tracks with the q parameter like
http://api.soundcloud.com/tracks?q=ewkqtieorak&client_id=MY_CLIENT_ID&format=json&_status_code_map%5B302%5D=200
, responses are empty array as I expect, but with the genres parameter like
http://api.soundcloud.com/tracks?genres=hoge&client_id=MY_CLIENT_ID&format=json&_status_code_map%5B302%5D=200
, responses are always 503 (I tried about 500 times).
The /tracks endpoint return status 503 so often even with existing genres that I am not sure it means there are not such genres or SoundCloud is having a server trouble. Are there any ways to distinguish them?
2. It seems that the filter parameter doesn't work correctly.
Example requests are below. I wanted streamable tracks and added "streamable" as a filter parameter, but response tracks include some unstreamable tracks. Am I using it incorrectly?
http://api.soundcloud.com/tracks?filter=streamable&genres=electronica&client_id=MY_CLIENT_ID&format=json
http://api.soundcloud.com/tracks?filter=streamable&order=hotness&genres=jazz%2Cclassical&bpm[from]=0&bpm[to]=100&created_at[from]=2011-11-24%2000%3A00%3A00&created_at[to]=2012-02-22%2000%3A00%3A00&limit=5&client_id=MY_CLIENT_ID&format=json&_status_code_map[302]=200
http://api.soundcloud.com/tracks?filter=streamable&order=hotness&genres=jazz%2Cclassical&bpm[from]=0&bpm[to]=100&created_at[from]=2012-01-03%2000%3A00%3A00&created_at[to]=2012-04-02%2000%3A00%3A00&limit=30&client_id=MY_CLIENT_ID&format=json&_status_code_map[302]=200

Proper resource names of a REST API

Let's say we are making an invoice API. What is a more appropriate resource?
GET
paid_invoices
due_invoices
all_invoices
or
GET
invoices/all
invoices/due
invoices/paid
Additional question: If your API allows marking invoices as paid what's the proper resource?
PUT //where 3 is the id
invoices/3
or
PUT
pay_invoice/3
I would say:
GET /invoices returns all invoices;
A filter can return either paid or due invoices: GET /invoices?state=paid where state can be paid or due.
To mark an invoice as paid, you can either set the corresponding state to your resource, and then you just have to update (replace actually) it using PUT /invoices/<id>.
Alternatively, you can patch your resource: PATCH /invoices/<id>. This method requires a diff like state=paid for example.
It's just a matter of what you want to send to your API (a complete resource, or just the change to apply).
A non-REST solution could be to perform a PATCH request to /invoices/<id>/paid. It's not pure REST but it's ok.

Restlet using Get and Post Methods

Hiiii,
I am developing a small app using Restlet 2.0 API..
I want just to know how to create a URI which accepts more than one parameter for insert query.
Ex:
router.attach("/{patient}/insertpatient", insertpatient);
I want to insert all the info about the patient using POST.
Or Search by ID and address for instance using GET.
thanks,
For the "insert patient" operation, I'd suggest something like a POST to /patients (if the server generates the patient ID) or a PUT to /patients/{patient-id} (if the client generates the patient ID). Either way, the body of the message would contain all of the input data needed to create a new patient entity. Two simple options for serializing the data would be as a URL-encoded form or as JSON.
Lookup by by ID could be a simple as a GET on /patients/{patient-id}. Lookup by address could also be a GET, possibly using a URL-encoded query parameter. For example, you could fetch the patient at address "123 Main Street, apt 4, Anytown, USA, 98765" with a GET on /patients?addr=%20Main%20Street%2C%20apt%204%2C%20Anytown%2C%20USA%2C%2098765

Google map geocoding address parser

I want to parse the addresses from Google geocoding API and store it as:
address
city
state
zipcode
country
Some places has full address from Google map and some just half, how can i know which part of the address is city, state or country? or just zipcode?
It would be helpful if some expert pointed out some help here.
In the response the geocoding API breaks up the address into AdministrativeAreaName (usually State) and SubAdministrativeArea. The SubAdministrativeArea area includes LocalityName (City), PostalCodeNumber (Zip Code) and Thoroughfare (Street Name and Number). For an example see: http://maps.google.com/maps/geo?q=1%20Infinite%20Loop,%20Cupterino,%20Ca. This is a geocode requst for Apple's Headquarters which has an address of 1 Infinite Loop, Cupterino, CA 95014.