rchavelas90 / routexl_python_req Goto Github PK
View Code? Open in Web Editor NEWScript to request get and post from python
Script to request get and post from python
Results are the same to the ones on documentation (https://www.routexl.nl/blog/api/?lang=en#post-tour) [See total distance = 160.5]
Update: I think I was not very clear explaining what I got. The script I made prints out the key information in a tabular format so that it is easier to use (This just extracts the info from the JSON to a tabular DataFrame object). In the two sessions that are printed below, I'm getting different results from one run to another. From what I can see the server that is used returns different results, I also notice that the router values that are returned within the "post distance" are all 1 in one server but 0 in the other. I'm guessing this haves something to do with the solver in the server, but I'm far too inexperienced with API's to even dare to state what is happening, this is just a kind and (hopefully) useful observation.
%run "/Users/Ricardo/Dropbox/Proyectos/RouteXL_Python_Req/RouteXL_Api_Read.py"
<Response [200]>
200
{'content-length': '174', 'content-encoding': 'gzip', 'x-powered-by': 'PleskLin', 'vary': 'Accept-Encoding', 'server': 'nginx', 'connection': 'keep-alive', 'date': 'Mon, 02 Feb 2015 05:33:59 GMT', 'content-type': 'application/json'}
{"id":"RouteXL API 1.3","datetime":"2015-02-02 06:33:59","load":23,"solvers":{"Server2 live":1000,"WS2611@WBC":0,"selected":{"server":"WS2611@WBC","load":0}},"echo":"Hello world","max_locations":10}
https://api.routexl.nl/status/Hello%20world
address lat lng
0 The Hague, The Netherlands 52.054290 4.248618
1 The Hague, The Netherlands 2 52.076892 4.269750
2 Uden, The Netherlands 51.669946 5.618520
3 Sint-Oedenrode, The Netherlands 51.589548 5.432482
<Response [200]>
{"count":4,"distances":{"0":{"from":0,"to":1,"distance":3850,"duration":305,"router":true},"1":{"from":0,"to":2,"distance":134646,"duration":5399,"router":true},"2":{"from":0,"to":3,"distance":128881,"duration":5443,"router":true},"3":{"from":1,"to":2,"distance":133251,"duration":5266,"router":true},"4":{"from":1,"to":3,"distance":127486,"duration":5310,"router":true},"5":{"from":2,"to":1,"distance":134764,"duration":5366,"router":true},"6":{"from":2,"to":3,"distance":23361,"duration":1173,"router":true}},"maxDistance":false,"skipValues":false,"solver":"WS2611@WBC"}
from to distance duration router
0 0 1 3850 305 1
1 0 2 134646 5399 1
2 0 3 128881 5443 1
3 1 2 133251 5266 1
4 1 3 127486 5310 1
5 2 1 134764 5366 1
6 2 3 23361 1173 1
<Response [200]>
{"id":"166O8W93","count":4,"feasible":true,"route":{"0":{"name":"The Hague, The Netherlands","arrival":0,"distance":0},"1":{"name":"The Hague, The Netherlands 2","arrival":5,"distance":3.9},"2":{"name":"Uden, The Netherlands","arrival":93,"distance":137.1},"3":{"name":"Sint-Oedenrode, The Netherlands","arrival":112,"distance":160.5}}}
name arrival distance
0 The Hague, The Netherlands 0 0.0
1 The Hague, The Netherlands 2 5 3.9
2 Uden, The Netherlands 93 137.1
3 Sint-Oedenrode, The Netherlands 112 160.5
Buggy results! [See total distance = 121.6]
%run "/Users/Ricardo/Dropbox/Proyectos/RouteXL_Python_Req/RouteXL_Api_Read.py"
<Response [200]>
200
{'content-length': '184', 'content-encoding': 'gzip', 'x-powered-by': 'PleskLin', 'vary': 'Accept-Encoding', 'server': 'nginx', 'connection': 'keep-alive', 'date': 'Mon, 02 Feb 2015 05:35:53 GMT', 'content-type': 'application/json'}
{"id":"RouteXL API 1.3","datetime":"2015-02-02 06:35:53","load":8,"solvers":{"Server2 live":1000,"WS2611@WBC":2,"Server3@Amazon":0,"selected":{"server":"Server3@Amazon","load":0}},"echo":"Hello world","max_locations":10}
https://api.routexl.nl/status/Hello%20world
address lat lng
0 The Hague, The Netherlands 52.054290 4.248618
1 The Hague, The Netherlands 2 52.076892 4.269750
2 Uden, The Netherlands 51.669946 5.618520
3 Sint-Oedenrode, The Netherlands 51.589548 5.432482
<Response [200]>
{"count":4,"distances":{"0":{"from":0,"to":1,"distance":2899,"duration":205,"router":false},"1":{"from":0,"to":2,"distance":103321,"duration":4572,"router":false},"2":{"from":0,"to":3,"distance":96389,"duration":4304,"router":false},"3":{"from":1,"to":2,"distance":103059,"duration":4562,"router":false},"4":{"from":1,"to":3,"distance":96537,"duration":4310,"router":false},"5":{"from":2,"to":1,"distance":103059,"duration":4562,"router":false},"6":{"from":2,"to":3,"distance":15646,"duration":887,"router":false}},"maxDistance":false,"skipValues":false,"solver":"Server3@Amazon"}
from to distance duration router
0 0 1 2899 205 0
1 0 2 103321 4572 0
2 0 3 96389 4304 0
3 1 2 103059 4562 0
4 1 3 96537 4310 0
5 2 1 103059 4562 0
6 2 3 15646 887 0
<Response [200]>
{"id":"z4cWD13M","count":4,"feasible":true,"route":{"0":{"name":"The Hague, The Netherlands","arrival":0,"distance":0},"1":{"name":"The Hague, The Netherlands 2","arrival":3,"distance":2.9},"2":{"name":"Uden, The Netherlands","arrival":79,"distance":106},"3":{"name":"Sint-Oedenrode, The Netherlands","arrival":94,"distance":121.6}}}
name arrival distance
0 The Hague, The Netherlands 0 0.0
1 The Hague, The Netherlands 2 3 2.9
2 Uden, The Netherlands 79 106.0
3 Sint-Oedenrode, The Netherlands 94 121.6
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.