I am trying to develop an ios app using the newly published NEST api but bit lost with their native documentation.
Question:I could get an access token but do not know the thermostat endpoint to query and update "Away" state
Any pointers will be greatly appreciated ..
I'm presuming you intend to use REST to query and update the away state since you mentioned "endpoint"? If not the other alternative is to use the firebase API. This is documented in the introduction section
To get the away status you'll need to query the structure/s
curl -v -L https://developer-api.nest.com/structures?auth=<AUTH_TOKEN>
The response shows the away state in addition to the thermostats/smoke co alarms in that structure.
{
"g-9y-2xkHpBh1MGkVaqXOGJiKOB9MkoW1hhYyQk2vAunCK8a731jbg": {
"away": "home",
"country_code": "US",
"name": "Home",
"smoke_co_alarms": [
"0NBM7-QfoLwhMldZ2CoIkQ7hRJoe1Jye"
],
"structure_id": "g-9y-2xkHpBh1MGkVaqXOGJiKOB9MkoW1hhYyQk2vAunCK8a731jbg",
"thermostats": [
"GM6Z9JpSKU6_ua8AfD6WRA"
],
"time_zone": "America/Los_Angeles"
}
}
To update the away state you would need to use the PUT http verb:
curl -v -L -X PUT "https://developer-api.nest.com/structures/g-9y-2xkHpBh1MGkVaqXOGJiKOB9MkoW1hhYyQk2vAunCK8a731jbg?auth=<AUTH_TOKEN>" -H "Content-Type: application/json" -d '{"away":"away"}'
Note that the ID used in the path parameter is the structure ID returned in the get response.
Hope that helps
Nagesh
Related
I just downloaded and installed CouchDB v3.
On first start, it prompted me to set an admin password which I did.
For the web app that I'm building, I want to use the CouchDB user authentication feature, so I created a new _users database using the Fauxton UI.
After creating the _users database I made a call to the REST API to insert a new user (this is the example code taken from the documentation):
$ curl -X PUT http://localhost:5984/_users/org.couchdb.user:jan \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"name": "jan", "password": "apple", "roles": [], "type": "user"}'
Instead of the expected response
{"ok":true,"id":"org.couchdb.user:jan","rev":..."}
I'm getting
{"error":"unauthorized","reason":"You are not authorized to access this db."}
When adding the admin credentials to the API call, it works as expected:
$ curl -X PUT http://admin:____#localhost:5984/_users/org.couchdb.user:jan \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"name": "jan", "password": "apple", "roles": [], "type": "user"}'
{"ok":true,"id":"org.couchdb.user:jan","rev":"..."}
My question:
Are there any settings or permissions I can set to make the request work without having to add the admin credentials? (AFAIK this worked fine in v2.x)
You are missing the fun of the good old Admin Party, which for many years was the default setting for CouchDB, meaning it was installed with zero security as everyone was effectively an admin.
From The Road to CouchDB 3.0: Security[1]
One of the aspects of getting started easily was a 1.x-era choice to
make it easy to use CouchDB: the Admin Party. Admin Party means that,
by default, any request made against CouchDB was done in the context
of an admin user, i.e. you were allowed to do anything.
3.0 changed all of that by shutting down the Admin Party - what a bunch of buzz kills!
I suspect there are more sophisticated solutions, but for those that want to party on[2] quickly, minor changes to etc/local.ini and any permissions on _users will satisfy.
The key is the configuration property require_valid_user[3].
In etc/local.ini, modify the chttpd and couch_httpd_auth sections
[chttpd]
require_valid_user = false
[couch_httpd_auth]
require_valid_user = false
That's all that is needed unless there are members and/or roles defined for the _users database. If there are, they must be deleted (easily with Fauxton).
After cleaning up members/roles and altering the etc/local.ini restart CouchDB and you should be able to create users without a problem. Party on! 👍
Just be sure to consider the ramifications of such changes.
Disclaimer - I don't recommend running CouchDB in any security context resembling Admin Party!
1 The Road to CouchDB 3.0: Security
2 Party On
3 require_valid_user
For example I want to receive only project names:
https://gitlab.com/api/v4/groups/:id/projects?fields=name
Is that possible?
That's not possible in the REST API. But, GitLab is working on GraphQL support, and you'd be able to express that in GraphQL.
https://docs.gitlab.com/ee/api/graphql/
To iterate on Vonc & King Chung Huang 's answers, using the following GraphQL query, you can get only the name field of the projects inside your group :
{
group(fullPath: "your_group_name") {
projects {
nodes {
name
}
}
}
}
You can go to the following URL : https://$gitlab_url/-/graphql-explorer and past the above query
Using curl & jq :
gitlab_url=<your gitlab host>
access_token=<your access token>
group_name=<your group name>
curl -s -H "Authorization: Bearer $access_token" \
-H "Content-Type:application/json" \
-d '{
"query": "{ group(fullPath: \"'$group_name'\") { projects { nodes { name }}}}"
}' "https://$gitlab_url/api/graphql" | jq '.'
GitLab 1.11 (May 2019) has now introduced a "basic support for group GraphQL queries "
GraphQL APIs allows users to request exactly the data they need, making it possible to get all required data in a limited number of requests.
In this release, GitLab is now supporting basic group information support in the GraphQL API.
See Issue 60786 and documentation: "Available queries"
A first iteration of a GraphQL API includes the following queries
project : Within a project it is also possible to fetch a mergeRequest by IID.
group : Only basic group information is currently supported.
I finally figured out how to create subscription. And it works fine, I get pushes from Instagram everytime I add new media.
Now the problem is, I've set up a mechanism so that our users can sync their insta to our site. So I should be able to create multiple subscriptions to the same client_id. From what I understand subscriptions is built to do just that. Now when another user comes along and creates a new subscription the other one (created with another instagram account) is getting deleted and replaced. I receive a successful instagram subscription with the exact same subscription_id as the one for my other subscription. When I list the subscriptions with curl I only see 1 subscription with the subscription_id 0.
{"data": [{"id": 0, "type": "subscription", "object": "user", "object_id": null, "aspect": "media", "subscription_id": 0, "callback_url": "**callbackurlReplacedForSecurityReasons"}], "meta": {"code": 200}}
How can this be?
From the docs the call to create the subscription looks like this:
curl -F 'client_id=CLIENT-ID' \
-F 'client_secret=CLIENT-SECRET' \
-F 'object=user' \
-F 'aspect=media' \
-F 'verify_token=myVerifyToken' \
-F 'callback_url=http://YOUR-CALLBACK/URL' \
https://api.instagram.com/v1/subscriptions/
Now I've set the verify_token to a unique string for each call in order to test if that was the problem as the doc said it should be individual for every request but it did not matter, same problem.
The problem exists for Sandbox mode and Live mode.
Is there anything else I am missing here? Am I getting this whole feature wrong? Is there only a way to create 1 subscription per client_id but if so why does it give me back a subscription_id?
Ok I've figured it out myself by surfing the web somewhere I've found a hint that enlighted me :D It is really poorly documented how subscriptions work on instagram side.
I was getting that feature completely wrong. My understanding was, that I have to create a subscription per user and if the user don't want it anymore he just deletes it.
How it really works is as follows:
You create 1 subscription for the whole client (not every user). Each user just has to authorize the application and THATS IT! Your callback method will now receive all updates of those users who have authorized your client. If they don't want it anymore they either have to deauthorize your client (which is very unlikely that he will find that option ;)) or you just don't react to incoming messages anymore.
A bit off topic but good to know:
I also want to add the structure of the json that is coming from insta to your callback because this is not documented on instagram side (you have no idea what you get without testing it yourself)
the json you receive when new media is posted looks as follows:
[{
"object": "user",
"object_id": "4857061161",
"changed_aspect": "media",
"time": 1502958709,
"data": {
"media_id": "1583254852313311736_4857061161"
},
"subscription_id": 0
}]
object_id is the instagram user id which you can use to differentiate between users and map to your internal user in the authorization process!
Also notice that it is wrapped in an array for whatever reason...
When downloading Event Logs, is it possible to get them using the API instead of downloading them via the Download CSV button on a web browser?
Is there an API for which it is possible among the URLs below?
https://developer.yahoo.com/flurry/docs/api/code/analyticsapi/
Also, if you plan to add it in the future, please let me know when it is scheduled for completion.
I appreciate your assistance.
There is no API for get Event Logs(raw data) as far as I know.
Workaround:
Downloading Event Logs CSV can be done something like
this with some additional touch. That implementation is for previous version.
After Flurry's renovation at 3/27/2017,
Log in via GET /auth/v1/session with credentials
Get 'flurry-auth-token' from GET /auth/v1/authorize
Call GET ../eventLogCsv with 'flurry-auth-token' to download CSV
I'm a user of Flurry. And hope they support this feature via API soon.
As of moment of writing, Flurry now provides Raw Data Download API, so you can retrive your raw event's data on a periodic basis (but within some limitations - time windows must be less than 1 month, data preparation takes some time, etc.)
Simplified workflow is following:
1. Setup
First of all, you must generate a Programmatic Token (discrabed here https://developer.yahoo.com/flurry/docs/api/code/apptoken/, process is straightforward, except that you'll need to create another user with different role in order to use this token)
2. Making the Request
Specify startTime/endTime for desired time window inside request (within other parameters):
curl -X POST https://rawdata.flurry.com/pulse/v1/rawData
-H 'accept: application/vnd.api+json'
-H 'authorization: Bearer ~~YOUR TOKEN~~'
-H 'cache-control: no-cache'
-H 'content-type: application/vnd.api+json'
-d '{"data": {
"type": "rawData",
"attributes": {
"startTime": "1511164800000",
"endTime": "1511251199000",
"outputFormat": "JSON",
"apiKey": "AAAA1111BBBB2222CCCC"
}
}
}'
If your request was successful (requestStatus equals Acknowledged inside response body), save the id value from response.
3. Checking for data preparation status
Depending on complexity of your app and requested time window, data preparation make take about 30 minutes up to a few hours to be prepared.
You can check status by using:
curl -g https://rawdata.flurry.com/pulse/v1/rawData/26?fields[rawData]=requestStatus,s3URI
-H ‘accept: application/vnd.api+json;’
-H ‘authorization: Bearer ~~YOUR TOKEN~~’
-H ‘cache-control: no-cache’
-H ‘content-type: application/vnd.api+json;’
As soon as your data is ready, response will be following:
{
"data":{
"type":"rawData",
"id":"26",
"attributes":{
"requestStatus":"Success",
"s3URI":"https://flurry-rdd.s3.amazonaws.com/downloads/26.JSON.gz?AWSAccessKeyId=AAAA1111BBBB2222CCCC&Expires=1513101235&Signature=h%2FChXRi5QwmvhUrkpwq2nVKf8sc%3D"
}
}
}
Save s3URI for next step.
4. Retrieving Results
Now you can retrieve archived raw data by using s3URI:
curl -O https://flurry-rdd.s3.amazonaws.com/downloads/26.JSON.gz?AWSAccessKeyId=AAAA1111BBBB2222CCCC&Expires=1513039053&Signature=xbKNnTgpv1odAfVgPRLMyck8UnE%3D
Source: https://developer.yahoo.com/flurry/docs/analytics/rdd/
Does anyone know of an service / api that lets you send a group message? I've been searching through Twilio's docs - seems like you can only send a message to one person.
Ideal use case:
[API Number] ----Sends Text----> (Friend 1 + Friend 2 + Friend 3)
And the result is a group message with 4 people in it - the three friends and the API.
d7networks.com is doing it with their RESTful API
========================================================
curl -X POST -H 'Authorization: Basic xxxxxxx==' -d '{
"messages": [
{
"to": [
"777771",
"777772",
"777773"
],
"content": "Same content goes to 3 numbers",
"from": "TEST"
}
]
}' http://sms.d7networks.com:8080/secure/sendbatch
You can't do it exactly as you describe but you can build something that creates a group SMS where everyone is texting the same #. This blog post shows how to build a group messaging app like this with Meteor, MongoDB and Twilio.
As far as I can tell http://www.bandwidth.com is the only sms api that supports group texting. You can see it in action at https://bandwidth.wistia.com/medias/ymd7q9utm0#. Unfortunately their trial doesn't have access to this feature (the trial uses api v1 and this is a feature of api v2) and there's no easy way to sign up for an account.