Why not ask your question on the new OpenStreetMap Community Forum?


Does file_get_contents require api key?

Currently the below statement doesnt work from PHP.

$json= file_get_contents("https://nominatim.openstreetmap.org/search?q=".$address."&format=json&polygon=1&addressdetails=1");

I could use file_get_contents with other geocode api.

What could be the problem? with nominatim Regards.

asked 30 Nov '20, 07:06

migandhi's gravatar image

accept rate: 0%

file_get_contents can open a file or a URL. For a URL the setting allow_url_fopen needs to be enabled on your system. I think that's enabled by default, but doublecheck. See https://www.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen

Make sure you're sending the HTTP UserAgent or Referer as required by https://operations.osmfoundation.org/policies/nominatim/ , see https://help.openstreetmap.org/questions/59788/calling-nominatim-with-file_get_contents

$address might contain special characters or spaces, the value needs to be URI encoded, see https://www.php.net/manual/en/function.urlencode.php

&polygon=1 still works but is deprecated, instead specify which format the polygon would have, see https://nominatim.org/release-docs/latest/api/Search/#polygon-output

permanent link

answered 30 Nov '20, 12:35

mtmail's gravatar image

accept rate: 27%



I saw all the links,

The below link has information that email address is required.


This worked for me.


(30 Nov '20, 13:40) migandhi
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 30 Nov '20, 07:06

question was seen: 1,856 times

last updated: 02 Dec '20, 14:06

powered by OSQA