Restify very simple JSONClient returns empty json - api

I just started using restify and tries to build a very simple JSONClient and fails on the first step.
var restify = require('restify');
var client = restify.createJsonClient({
url: 'http://api.bgm.tv'
});
client.get('/calendar', function(err, req, res, obj) {
console.log('%j', obj);
});
This pieces of code returns {} with a status code 200
If you check http://api.bgm.tv/calendar in browser or curl it seems to be a legit json GET Rest API and does not require auth or anything else.
I tried other API such as stackoverflow api it works perfectly, so I assume something wrong with the server side?
If anyone can try to run it and help me point out what might went wrong would be very appreciated.

I runned your example node code and got a proper response (the same you get when browsing).
You probably have some version problem or a console.log size limitation.
Try using: console.log(obj[0]); it should print only the first object in the json.
I'm using node v0.8.9 and restify v2.4.1 on a mac.

Yeah, when I use the Postman plugin for Chrome and do a GET request to http://api.bgm.tv/calendar I get:
[
{
"weekday": {
"en": "Mon",
"cn": "星期一",
"ja": "月耀日",
"id": 1
},
"items": [
{
"id": 46458,
"url": "http://bgm.tv/subject/46458",
"type": 0,
"name": "アイカツ! -アイドルカツドウ!-",
"name_cn": "偶像活动",
"summary": "",
"eps": 0,
"air_date": "2012-10-08",
"air_weekday": 1,
"images": {
"large": "http://lain.bgm.tv/pic/cover/l/db/7f/46458_8mM39.jpg",
"common": "http://lain.bgm.tv/pic/cover/c/db/7f/46458_8mM39.jpg",
"medium": "http://lain.bgm.tv/pic/cover/m/db/7f/46458_8mM39.jpg",
"small": "http://lain.bgm.tv/pic/cover/s/db/7f/46458_8mM39.jpg",
"grid": "http://lain.bgm.tv/pic/cover/g/db/7f/46458_8mM39.jpg"
},
"collection": {
"wish": 0,
"collect": 0,
"doing": 44,
"on_hold": 0,
"dropped": 0
}
},
{
"id": 57150,
"url": "http://bgm.tv/subject/57150",
"type": 0,
"name": "LINE OFFLINE ~サラリーマン~",
"name_cn": "离线LINE - 上班族 -",
"summary": "",
"eps": 0,
"air_date": "2013-01-07",
"air_weekday": 1,
"images": {
"large": "http://lain.bgm.tv/pic/cover/l/71/28/57150_Kz171.jpg",
"common": "http://lain.bgm.tv/pic/cover/c/71/28/57150_Kz171.jpg",
"medium": "http://lain.bgm.tv/pic/cover/m/71/28/57150_Kz171.jpg",
"small": "http://lain.bgm.tv/pic/cover/s/71/28/57150_Kz171.jpg",
"grid": "http://lain.bgm.tv/pic/cover/g/71/28/57150_Kz171.jpg"
},
"collection": {
"wish": 0,
"collect": 0,
"doing": 206,
"on_hold": 0,
"dropped": 0
}
},
{
"id": 58709,
"url": "http://bgm.tv/subject/58709",
"type": 0,
"name": "ハヤテのごとく! Cuties",
"name_cn": "旋风管家 Cuties",
"summary": "",
"eps": 0,
"air_date": "2013-04-08",
"air_weekday": 1,
"images": {
"large": "http://lain.bgm.tv/pic/cover/l/15/28/58709_H7uj8.jpg",
"common": "http://lain.bgm.tv/pic/cover/c/15/28/58709_H7uj8.jpg",
"medium": "http://lain.bgm.tv/pic/cover/m/15/28/58709_H7uj8.jpg",
"small": "http://lain.bgm.tv/pic/cover/s/15/28/58709_H7uj8.jpg",
"grid": "http://lain.bgm.tv/pic/cover/g/15/28/58709_H7uj8.jpg"
},
"collection": {
"wish": 0,
"collect": 0,
"doing": 219,
"on_hold": 0,
"dropped": 0
}
},
...and a bunch more, but the body limit to answers on SO is 30,000 characters.

Related

How to add query parameters in Zoom API (GET) request?

I'm trying to get all meeting recordings saved in the cloud in a date range using using the following API:
https://marketplace.zoom.us/docs/api-reference/zoom-api/cloud-recording/recordingslist
This is the API response I'm getting in postman.
{
"from": "2021-06-01",
"to": "2021-06-02",
"page_count": 1,
"page_size": 30,
"total_records": 1,
"next_page_token": "",
"meetings": [
{
"topic": "Meeting Room",
"type": 4,
"start_time": "2021-06-02T10:00:47Z",
"timezone": "Asia/Calcutta",
"duration": 0,
"total_size": 0,
"recording_count": 0,
"recording_files": [
{
"recording_start": "2021-06-02T10:02:39Z",
"recording_end": "2021-06-02T10:05:29Z",
"file_type": "MP4",
"file_extension": "MP4",
"file_size": 3181252,
"status": "completed",
"recording_type": "shared_screen_with_speaker_view"
},
{
"recording_start": "2021-06-02T10:02:39Z",
"recording_end": "2021-06-02T10:05:29Z",
"file_type": "M4A",
"file_extension": "M4A",
"file_size": 2694678,
"status": "completed",
"recording_type": "audio_only"
}
]
}
]
}
I am unable to get all the recordings of the desired time range. The "from" and "to" parameters are not changing even after trying the below query.
https://api.zoom.us/v2//users/me/recordings?from="2020-07-01"&to="2021-06-01"
In postman use this API
https://api.zoom.us/v2/users/{{user id}}/recordings?from=2022-01-01&meeting_id={{meeting id}}
Thanks to #ajaidanial

(CoinMarketCap) Different response from API call

Before the API was working properly but now it does not work well, its response got change and I don't know why
Previous response seems understandable:
Which the 2782 read as AUD and its name is properly assigned and does not return object on data property.
{
"status": {
"timestamp": "2021-04-20T00:35:36.456Z",
"error_code": 0,
"error_message": null,
"elapsed": 7,
"credit_count": 1,
"notice": null
},
"data": {
"id": 2782,
"symbol": "AUD",
"name": "Australian Dollar",
"amount": 88,
"last_updated": "2019-08-30T18:51:00.000Z",
"quote": {
"USDT": {
"price": 58.995907552127,
"last_updated": "2019-08-30T18:51:12.000Z"
}
}
}
}
Newer Response:
On this response the data property got a result of object which parent is the converted or symbol then its information, notice that the id and name does not match with 2782 (AUD). it became random string or something and also the conversion rate seems like not reasonable at all.
{
"status": {
"timestamp": "2021-05-20T08:25:05.561Z",
"error_code": 0,
"error_message": null,
"elapsed": 1,
"credit_count": 1,
"notice": null
},
"data": {
"AUD": {
"symbol": "AUD",
"id": "kg7up6o9tzp",
"name": "kz7fw7rlj8",
"amount": 88,
"last_updated": "2021-05-20T08:25:05.561Z",
"quote": {
"BTC": {
"price": 5691,
"last_updated": "2021-05-20T08:25:05.561Z"
}
}
}
}
}
This are the parameters I sent bot previous and newer call
{
"amount": 12,
"convert": "BTC",
"id": 2782 # AUD
}
UPDATE::
At some point when using the production version of API URL the result backs to normal
I don't know yet the explanation regarding on this issue, is there something limit on the sandbox api or so?

How to decode JSON list using sql statements in AWS IoT core?

Here I have displayed the payload that I am trying to decode in AWS
IoT core rules to push that to AWS DynamoDB.
{
"adr": true,
"applicationID": "1",
"applicationName": "IOTAPPS",
"data": "AANl3AAAQT8AZA==",
"devEUI": "sadfgxvgsfxgs245",
"deviceName": "TRON002",
"fCnt": 0,
"fPort": 2,
"object": {
" A1": "NO",
"A10": "YES",
"A11": "YES",
"A12": "YES",
"EGHmpID": 222684,
"SelFFMac": 100,
"TOTAL_DATA": "100000100111111"
},
"rxInfo": [
{
"gatewayID": "FDFDFEF5584EDEef",
"location": {
"altitude": 0,
"latitude": 12.66885,
"longitude": 77.81253
},
"name": "IoTGateway",
"fddi": -94,
"time": "2019-11-18T09:02:08.895349Z"
}
],
"txInfo": {
"dr": 5,
"frequency": 898678700000
}
}
We are trying to fetch 'time' from 'rxInfo' list by using following sql statement.
SELECT deviceName,(SELECT VALUE time FROM rxInfo) AS time FROM "my/topic"
We are not getting the expected answer
Try this, it's tested on AWS IoT.
SELECT (SELECT time fROM rxInfo) AS time FROM "abc/cmd"
to generate this output:
{
"time": [
{
"time": "2019-11-18T09:02:08.895349Z"
}
]
}
cheers,
ram

How to validate properties in loopback remote method?

Recently I have started learning Loopback. I have tried to add required, min and max.
Here is my remote method in json file with parameters :
{
"name": "registration",
"methods": {
"registrationIn": {
"accepts": [
{
"arg": "firstname",
"type": "string",
"min": 1,
"max": 25, // same for here
"required": true,
"description": "Firstname of the person.",
"http": {
"source": "form"
}
}
{
"arg": "mobile",
"type": "number",
"min": 1, // since required it correct but not checking i removed required
"max": 10, // not working
"required": true, // working
"description": "",
"http": {
"source": "form"
}
}
],
"returns": [],
"description": "This method used to registration.",
"http": [{
"path": "/registrationIn",
"verb": "post"
}]
}
}
required property is working fine but min and max is not working.
Can anyone guide me to where i am doing wrong ?
Thanks
Please refer this link validation
You can add validation on model.
module.exports = function(user) {
user.validatesLengthOf('password', {min: 5, message: {min: 'Password is too short'}});
}

Converting a Review API call to html

I am sorry to trouble.
I am unable to convert an API call into html that can go on a web page.
The call is like this:
https://api.feefo.com/api/version/reviews/summaryall?merchant_identifier=example-retail-merchant
And it produces something like this:
{
"merchant": {
"identifier": "example-retail-merchant",
"name": "Example Retail Merchant",
"url": "http://www.exampleretailmerchant.co.uk",
"logo": "example-retail-merchant-logo.png",
"review_url": "http://www.feefo.com/en_GB/reviews/example-retail-merchant"
},
"meta": {
"count": 3878,
"pages": 194,
"page_size": 20
},
"rating": {
"min": 1,
"max": 5,
"rating": 4.9,
"service": {
"count": 3878,
"1_star": 8,
"2_star": 28,
"3_star": 0,
"4_star": 181,
"5_star": 3661
},
"product": {
"count": 6240,
"1_star": 55,
"2_star": 102,
"3_star": 0,
"4_star": 724,
"5_star": 5359
}
}
}
Can anyone please point me in the right directoion?
Thank you so much...
According to jQuery, you can use the following function to make API calls:
$(document).ready( function() {
var info;
var whitelisted;
var quantity;
$.get("https://api.guildwars2.com/v2/commerce/prices/24615",function(obj){
info = obj['id'];
whitelisted = obj["whitlelisted"]
quantity = obj.buys['quantity']
$("#id1").html("id :"+info);
$("#whitelist").html("whitelisted :"+whitelisted);
$("#quan").html("quantity :"+quantity);
});
});