This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

Why I receive Error 403 from API?

0

Good morning. I am a beginner of p.s.m. Firts I tried the following from the browser, and it worked and it still works: https://nominatim.openstreetmap.org/search?street=via+tolmezzo+15&postcode=20132&city=milano&county=MI&country_code=IT&format=json

Then I tried with php, with the following instructions, both from my pc that from a server, but it always return an Error 403. I read that this happens when there is an abuse, but it happened me from the very first submissmion. Thank you.

$data = array( 'street' => "via tolmezzo 15", 'postcode' => "20132", 'city' => "Milano", 'county' => "MI",
'country_code' => "IT", 'format' => "json" ); $options = array ( 'http' => array ( 'header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'GET', 'content' => http_build_query($data) ) ); $url="https://nominatim.openstreetmap.org/search"; $context = stream_context_create ($options); $result = file_get_contents ($url, false, $context);

asked 08 Jan '22, 20:19

enzovisk's gravatar image

enzovisk
11112
accept rate: 0%


2 Answers:

3

You are not following the Nominatim Usage policy, see here: https://operations.osmfoundation.org/policies/nominatim/

You'll have to be esp. careful about including a unique user agent for your application ;)

answered 08 Jan '22, 21:00

Spiekerooger's gravatar image

Spiekerooger
3.1k22356
accept rate: 16%

edited 09 Jan '22, 10:12

Thank you for your kind answer. I have read and I followed all these guidelines. It send me such response "error 43" since the first attempt, but all is right.

Afterwards,I tried from different servers and different connections. I also tried with curl. But It always gives me that answer.

Best regards. Vincent

(09 Jan '22, 09:57) enzovisk
1

No, you did not follow the instructions as laid out by the usage policy. I've added another hint in my answer above.

(09 Jan '22, 10:13) Spiekerooger

0

you should use an UserAgent var httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.UserAgent.ParseAdd("Mozilla/5.0 (compatible; AcmeInc/1.0)")

answered 18 Jan '24, 09:17

Nawar327's gravatar image

Nawar327
1
accept rate: 0%

Source code available on GitHub .