NOAA API Integration - javascript

Having trouble getting NOAA API to give the results I want. I have found the data that I would like to use but I cannot get the API to find it. I want to be able to search the records for the average first frost date based on zipcode. The data should be in the NORMAL_ANN dataset. When I use "https://www.ncdc.noaa.gov/cdo-web/api/v2/data?datasetid=NORMAL_ANN"; I get a bad request error.
Any ideas on what am I doing wrong? I can get the API to return objects when I use https://www.ncdc.noaa.gov/cdo-web/api/v2/datasets (and I confirmed that NORMAL_ANN is a valid dataset).
Thanks

Ok I found the answer. For 50% probability of first occurence of 28F, the below query is able to fetch a result
https://www.ncdc.noaa.gov/cdo-web/api/v2/data?datasetid=NORMAL_ANN&datatypeid=ANN-TMIN-PRBFST-T28FP50&startdate=2010-01-01&enddate=2010-01-01&&stationid=GHCND:USC00047821
The same data can be obtained from their UI tool here
https://www.ncdc.noaa.gov/cdo-web/datasets/NORMAL_ANN/stations/GHCND:USC00047821/detail
The rest query returns result like this:
{
"metadata": {
"resultset": {
"offset": 1,
"count": 1,
"limit": 25
}
},
"results": [
{
"date": "2010-01-01T00:00:00",
"datatype": "ANN-TMIN-PRBFST-T28FP50",
"station": "GHCND:USC00047821",
"attributes": "S",
"value": 361
}
]
}
How to interpret? Value 361 implies 361st day from the start of calendar year which would be 12/27. This confirms with the actual data. To view the actual data, click on "view data" for the station(I used San Jose, CA).

Related

Search text as keyword in array of object using Parse Platform or MongoDB aggregate

I have some data like this in my Class Object or my Collection.
{
"_id": "WI9jBNC13S",
"metadataMedia": [{
"media_id": "4329061",
"text": "Happy Birthday Mrs. #nurhida.amin"
}, {
"media_id": "4329062",
"text": "Please stay at home, keep healthy",
}, {
"media_id": "4329063",
"text": "Good morning sedulur 🎉\nSelamat hari Sabtuuuu",
}],
"username": "pblp",
"isMember": false,
"_session_token": "r:2b47ec8c482d7043437"
}
I am trying to get some data (big data expected) from my MongoDB using Parse Platform.
I want to build search feature (like search engine) to get data from "metadataMedia[].text" attribute.
I have two options, using Parse.Query.fullText() and MongoDB Text Search. I have no idea how to use one of them in array of object.
Could anyone help please?

How to get data from an endpoint API in realtime

I would like to get the live results from an Api endpoint preferably using javascript, nodejs. I am looking for more like a technique or idea how to handle this.
Api response looks as following:
[
{
"id": 6,
"team1": {
"name": "Home Team",
"goals": 2
},
"team2": {
"name": "Away Team",
"goals": 1
},
"starting": "2018-09-14T15:30:00Z"
}
]
Probably one way I can think of doing is making a new request every second and get up to date. So each time a team scores this api changes so I get the latest score goal results.
What is the best way I can handle this without overwhelming the resources of the server or probably not get banned from the API Endpoint if I am doing too many requests.

Get SoundCloud Artist Page? (Round 2)

I'm still trying to write a function in JavaScript where the user can type in an artist, and it will return a link to that artist's SoundCloud page.
For example,
/artist beyonce --> https://soundcloud.com/beyoncemusic
But the SoundCloud URLS don't all act the same. For example,
/artist dave matthews band --> https://soundcloud.com/dave-matthews-band.
For this reason, I can't simply just output scLink/artistName because they all have different URLs. I'm using Node.js, so I looked through a lot of npm packages, but couldn't figure out how to use any for this purpose. Perhaps Soundclouder will work somehow (though I couldn't figure it out myself). Does anyone know how I could write a command like this?
You are using the SoundCloud API, right?
A simple HTTP request to the right API should return the data you want. For example:
http://api.soundcloud.com/users.json?q=beyonce
[
{
"id": 4293843,
"kind": "user",
"permalink": "beyoncemusic",
"username": "Beyoncé",
"uri": "http://api.soundcloud.com/users/4293843",
"permalink_url": "http://soundcloud.com/beyoncemusic",
"avatar_url": "http://i1.sndcdn.com/avatars-000036935308-a2acxy-large.jpg?435a760",
"country": "United States",
"full_name": "Beyoncé",
"description": "",
"city": "New York",
"discogs_name": null,
"myspace_name": "beyonce",
"website": "http://www.beyonceonline.com",
"website_title": "",
"online": false,
"track_count": 33,
"playlist_count": 2,
"plan": "Pro Plus",
"public_favorites_count": 0,
"followers_count": 478783,
"followings_count": 0,
"subscriptions": [
{
"product": {
"id": "creator-pro-unlimited",
"name": "Pro Unlimited"
}
}
]
},
...
]
...so you could just do results[0].permalink_url.
You can use the request module to make the HTTP request manually, or use soundclouder to handle SoundCloud API's authentication details.
Most of the above does not apply if you want to make the actual requests from a browser. (The question is tagged node.js, but it sounds like you want to do this from a web page.)
If you're doing this from a webpage, use the SoundCloud JS SDK. The data you get back will look like the example above.
I don't think you'd be able to get an exact match reliably. Your best bet would be to search for users with the string you are looking for - example: "beyonce" and then to show the results and let them pick the correct link. You may be able to filter out likely results with follower count (high follower count) or something after you've pulled the initial list from soundcloud.
Search code:
users = SC.get('/users', { q: 'beyonce' });
Then iterate over users and display the permalink url. Hope this helps.

AngularJS, save data in a json and retrieve it allowing angular to rebuild a dynamic table

Good morning Everyone:
My angular app is a restaurant manager. Somwhere in the backend it shows a restaurant delivery manager, where delivery costs can be managed. I'm giving the option to the users (Restaurant admins) in the backend ui to add Delivery methods, and locations, so each combination has a price and it's saved to the json and displayed in a table below the inputs using ng-repeat
My json is something like this:
{
"deliveryLocation": [
{
"id": 1,
"location": "downtown"
}
],
"deliveryMethods": [
{
"id": 1,
"name": "Delivery Boy"
},
{
"id": 2,
"name": "Cab"
}
],
"combinations": []
}
So when you populate the inputs, you will have at least a combination, for ex: "Downtown - Cab". That combination will be stored in "combinations" (see json) with the following format: "deliveryLocation": "", "deliveryMethods": "", "price": 0
Where price will be an empty input in the combinations table. So the user indicates how much that delivery will cost and that will be saved in the combinations array. (For ex: "deliveryLocation": "downtown", "deliveryMethods": "cab", "price": 50).
I must send the data to the backend when the user saves the table. When the user opens the delivery manager again, the app will receive the data from the backend, will receive the same json, recovering deliveryLocations and deliveryMethods it's quite straightforward, but how should I indicate to AngularJS that everything that will be found in the combinations field is a combination of references? (deliveryLocation an deliveryMethods).
Thanks so much,
Guillermo
1st off take a look on this good example: Fiddle
This example demonstrates how to convert JSON object to table with angularjs.
So what you need to do:
1) with angular send your table object to your (suppose PHP) server side to DB by using some factory:
module.factory('ajax_post', ['$http', function(_http) {
var path = 'src/php/data.ajax.php'; // example
return{
init: function(jsonData){
var _promise= _http.post(path,
jsonData
,{
headers: {
'SOAPActions': 'http://schemas.microsoft.com/sharepoint/soap/UpdateListItems'
}
}
);
return _promise;
}
}
}]);
By the same way load table from DB.

gdata api v3 youtube, can not retrieve contentDetails

I am trying to get the duration of a youtube video via search
var request = gapi.client.youtube.search.list({
q: q,
type : "video",
maxResults : 10,
part: 'snippet,contentDetails'
});
as an additional part parameter I added contentDetails in order to get the duration as you can see in their doc.
https://developers.google.com/youtube/v3/getting-started
Now comes the silly part. The response I get is the following:
[
{
"error": {
"code": -32602,
"message": "contentDetails",
"data": [
{
"domain": "youtube.part",
"reason": "unknownPart",
"message": "contentDetails",
"locationType": "parameter",
"location": "part"
}
]
},
"id": "gapiRpc"
}
]
"As such, the part parameter requires you to select the resource components that your application actually uses"
Thats what I did and now they dont know their own parameter anylonger?
So I was wondering how can I retrieve the duration order contentDetails in general?
best
phil
As written in the document, for search->list call, part can only take value "snippet".
Depending on the kind of the response, as a secondary call, you can do one of videos->list, playlists->list, channels->list with the id and part=snippet,contentDetails to get more details of each result item.

Categories