I'm trying to use the New York City Bus API in order to create an app. The last API I worked with, was while learning Python. I have no idea where to begin.
This is the link to the documentation
http://bustime.mta.info/wiki/Developers/SIRIIntro
If you guys could point me towards how I can get the data from the API. I already got the Key.
Thank You so Much
You can use requests to fetch data from api.
import requests
url = "http://api.prod.obanyc.com/api/siri/vehicle-monitoring.json?key={}".format(key)
# fetch data
data = requests.get(url).json()
# do something with data.
Related
I am working with an api (Track-pod) and uploading JSON files to their server using a google apps script. I know this question has probably already been answered, but I have searched google extensively and couldn't find an answer, or maybe I just wasn't typing in the right keywords. Each Json file that I am uploading contains information on customers for the company I am working for. The way I am doing it is like so
for each(var item in array)
{
option.payload = JSON.stringify(item);
UrlFetchApp.fetch(url, option);
}
In my code the array is an array of objects for each customer. I was wondering if I have to constantly make requests, or is there a way to upload all the JSON files at once. Or at least make it faster.
To save some time you can use UrlFetchApp.fetchAll(). It will take an array of request as parameter and you can do up to 10 requests at the same time if I well remember.
Don't forget to check destination endpoint limit to not over charge it.
Reference : https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app#fetchAll(Object)
Stéphane
I would like to obtain the latest data by specifying Lambda's IoT Analytics dataset.
If you use getDatasetContent of IoTAnalytics of aws sdk, only the link for downloading the file will be returned.
Data itself can not be acquired.
I would like to know how to obtain information on the IoT Analytics data set from Lambda.
Hi and welcome to Stack Overflow!
If I understand your question correctly, you are asking how to get the data from an IoT Analytics Dataset using a Lambda function?
You are correct that get_dataset_content only returns the URI, but it is simple to then fetch the actual content, for example in Python it would look like this;
# Code Fragment to retrieve content from IoT Analytics Dataset
iota = boto3.client('iotanalytics')
response = iota.get_dataset_content(datasetName='my_data_set',versionId='$LATEST')
contentState = response['status']['state']
if (contentState == 'SUCCEEDED') :
url = response['entries'][0]['dataURI']
stream = urllib.request.urlopen(url)
reader = csv.DictReader(codecs.iterdecode(stream, 'utf-8'))
for record in reader:
# Process the record as desired, you can refer to columns in the CSV
# by using record['column_name'] using the DictReader iterator
Note that this code is specifically looking at the most recent results using the $LATEST version - you can also look for the $LATEST_SUCCEEDED version.
There's more documentation here for Boto - the AWS Python SDK, but you can use the same approach in all other sdk supported languages.
Hope that helps,
Roger
I have a API defined in my project which returns JSON data in response.
url(r'^api/report/(?P<report_id>\w+)/generate/', staff_member_required(api_views.GenerateReport.as_view()), name="generate_report"),
In another app of same project, I want to receive this data in views.py
How do I make a request to this url using some django functions.
I think there might be some way to make this GET request without using requests or any other 3rd party module.
Any help would be appreciated.
I am working on an application that get response from steam API. I am halfway through my task. Now I need some help on getting response of dota2 hero or item details that completely contains ìd name and image_url.
I want to know are there any steam API call to receive the response that I required?
Thanks in advance
You can use the following steam API call to get name, id and localized_name replace {ur_key} with the web API key that steam provided you.
https://api.steampowered.com/IEconDOTA2_570/GetHeroes/v0001/?key={ur_key}&language=en_us&format=JSON
But you need image URL too, you can use this json data of heroes and this data of items
I hope this would be helpful for you.
I'm started developement in xamarin cross platform development in visual studio. I want to know, how to retrieve the JSON message from url to show the details in table view. Here i give a sample url, how to retrieve all the city name in the json data and show in table. Help me!
url: http://api.wunderground.com/api/02e5dd8c34e3e657/geolookup/conditions/forecast/q/Dhaka,Bangladesh.json
As #Udi said, your question is too broad. But because of that, I'll give broad answers.
First, use HttpClient to retrieve the data from your url. Second, use Json.Net to deserialize your response into your entities/model.
string url = #"http://api.wunderground.com/api/02e5dd8c34e3e657/geolookup/conditions/forecast/q/Dhaka,Bangladesh.json";
using (var client = new HttpClient())
{
var result = await client.GetStringAsync(url);
return JsonConvert.DeserializeObject<YourModelForTheResponse>(result);
}
Third, to display your data, I would suggest going Xamarin.Forms or MonoTouch.Dialog. It makes using tables way easier.
I have a sample app that I queried a service, got a json response, and displayed the list of data using both Xamarin.Forms and MonoTouch.Dialog. Check out my sample app at github.
I posted this question on xamarin forums with complete coding. I got a answer from someone with complete coding structure. Its work for me.
click here to see the link with question and answer. I hope, it works for all u.