How to get Speed Limits extra information?


I am looking for a way to get speed limits information of the route.

Is there a way to do that?

Here ( I see I can get some extra info from the response, however, I have trouble creating a valid request
I am trying to do something like this:[MY_API_KEY]&start=[Start_location]&end=[End_location]&extra_info=“MaxSpeed” (or AvgSpeed, whatever).
What I am doing wrong?


we had smth like this before (avg_speed), but that was very inaccurate. And no one was using it so we threw it out.

If you really want it, you can calculate it yourself from the response. Every step in the segments object has duration and distance specified, giving you average speeds along (mostly multiple) waypoints.

EDIT: in fact it’s still there in the response if you specify attributes=avgspeed I just saw. But it’s only for each segment, which is very coarse. Unit is km/h it seems.

Thank you Nils.
And what is the correct syntax for specifying that?
I am trying it (among others) like this without success:[MY_API_KEY]&start=[Start_location]&end=[End_location]&attributes=avgspeed

Your support is much appreciated!

Try our API playground:{profile}/geojson/post

Really easy to see all configuration options and directly see the result on a map and it’s raw response. Look for the parameter attributes and choose avgspeed.

Yeah, there’s multiple things wrong with your query:

  1. No more GET requests, it’s all POST now, so your parameters go into the request body, not the query string (except for API key, which is still in the query string. Alternatively, use a request header Authorization: <api_key>)
  2. start/end is not how you use ORS. The parameter is coordinates and takes a simple [[Lon, Lat]] list.

It is still possible to use GET with our V1 Api, also available in the playground if you switch Api version to V1:|end&profile=driving-car&attributes=avgspeed

We strongly recommend to use the V2 api as V1 is deprecated and will not be supported in the future (approximately 1 year).

Thank you.
I am playing around with the API, and it seems like if “osmid” is required as extra info, it fails with api_key error.
Anything else seems to be working, only osmid is failing.
What’s the matter with it?

(Both for{profile}/geojson/post and{profile}/post)

Also, I am trying to implement it to Unity, and it seems I have a charset issue:

{“error”:{“message”:“Content type ‘application/x-www-form-urlencoded;charset=UTF-8’ not supported”},“info”:{“engine”:{“version”:“5.0”,“build_date”:“2019-02-28T09:09:39Z”},“timestamp”:1554196364097}}

So I have encoded the uri and the post data to ASCII and overwrote the header in the request, still it comes back with the same error

My code snippet (“request” = post data):

string notUTF8request = Encoding.ASCII.GetString(Encoding.UTF8.GetBytes(request), 0, request.Length);
string notUTF8URI = Encoding.ASCII.GetString(Encoding.UTF8.GetBytes(URI), 0, URI.Length);

    UnityWebRequest www = UnityWebRequest.Post(notUTF8URI, notUTF8request);
    www.SetRequestHeader("Authorization", API_Key);
    www.SetRequestHeader("Charset", "ASCII");
    yield return www.SendWebRequest();


Any idea?

content-type: application/json

1 Like

osm_id is not supported at this point, sorry.

Ok, I got it working, thank you for helping me getting there!

For anyone else trying to use it from Unity:

Use WWW instead of UnityWebRequest.

UnityWebRequest Post only supports posting a string in UFT-8.
I am not sure if the problem is the encoding or the fact that the posting seems to turn the string from this : “{ \ " coordinates \ " :…}” to this “{“coordinates”:…}” by the time it is getting sent, but as you have no option to control it by any ways or post raw data, you will get “JSONParseError: Unexpected character…”
(I had to add spaces to show what I wrote, as this site also converted \ + " to " )
(You could use Put instead of Post, but ORS does not support Put, so here it is not working).

You do not need UnityEngine.Networking, UnityEngine has WWW, for me it is working fine:

public string API_Key;
public string request;

public WWW Post(string request)
    Dictionary<string, string> postHeader = new Dictionary<string, string>();
    postHeader.Add("Content-Type", "application/json");
    postHeader.Add("Authorization", API_Key);
    byte[] requestData = Encoding.ASCII.GetBytes(request);
    WWW www= new WWW(URI, requestData, postHeader);
    return www;

IEnumerator WaitForRequest(WWW data)
    yield return data; // Wait until the download is done
    if (data.error != null)
        Debug.Log("There was an error sending request: " + data.error);
        Debug.Log("WWW Request: " + data.text);

It’s the max speed tag you want, if you want the speedlimits for each road.
This would be super useful.
I notice mapquest provide this.
I was hoping it might be possible to look this up programmatically but one would need the road id from OSM

A post was split to a new topic: Average speed calculation for different periods of time