Using the Datastore API to Request Entities Through JSON - python

I was wondering if anyone had experience with using the Datastore API through authorized JSON requests? I'm looking at the documentation here:
https://cloud.google.com/datastore/docs/apis/v1beta2/datasets/runQuery#try-it
...and honestly, the request body is a whole lot of 'what is going on here'.
I'm simply trying to make a query. Is there no way to request say, every Section entity in my database? Its so confusing :S

Related

HTML Request from Denticon

I am attempting to query a cloud database using the requests package. This is from Denticon, a dentistry software that my office uses to schedule patients and store information on the cloud about them and their dental history. Eventually, I would like to process and analyze the results of the query in pandas but I am having issues getting query to work at all. I admit I am a novice at using this sort of API and querying in general, so show some grace if I am doing this absolutely wrong.
By their own documentation, the makers of Denticon say you must query using a html request. When attempting to use 'request.get()' I get an error message that this method in not supported for the request when using it on a url for a specific query.
Here is some short documentation from their own website that could help fill some gaps:
Denticon API
Denticon API Getting Started
Denticon Patient APIs
In my case I am trying to query a list of patients at a specific office/location. This is what I would think to try:
import requests
apiKey = {"API-AUTH-KEY":"AAC6DB7A-5A66-4EBC-B694-D6BCD99881CB",
"API-VENDOR-KEY":"BCF756D4-DCE6-4F2B-BAAE-7679D87037A7",
"PGID":"1"}
requests.get('https://dev-api.denticon.com/v2/api/Patient/AllPatients/', headers=apiKey)
(As a short disclaimer: these are practice api keys that Denticon provides. They do not allow you query any actual patient data, just to practice using the API)
At this point is where I get the "method not supported" response for request.get
The error means that you cannot call the API using requests.get. Try to do it using requests.post.
import requests
apiKey = {"API-AUTH-KEY":"AAC6DB7A-5A66-4EBC-B694-D6BCD99881CB",
"API-VENDOR-KEY":"BCF756D4-DCE6-4F2B-BAAE-7679D87037A7",
"PGID":"1"}
json = {"OID":"","PAGEINDEX":"1"}
requests.post('https://dev-api.denticon.com/v2/api/Patient/AllPatients/', headers=apiKey, json=json)

HTTPS Post data from Lambda function for an Alexa Skill

I know that there are methods for sending a GET request with a vanilla Alexa Lambda function, but does the same thing exist for POSTing data to an HTTPS URL?
I want to post data to a URL when the user fires a certain intent in my skill.
Yes, there are.
This is a tutorial on creating POST method with JSON payload from Amazon Doc
Personally, I would prefer to modulate and separate out the code dealing with HTTP out from the Alexa Skill, and put it into another Lambda function. Of course, it's totally optional, but here are my reasons:
modularity for better debugging
cleaner code if you have multiple skill states.
If you are looking for some code example, I use to have a project that did similar job, hope you'll find the documentation helpful in some way.

API endpoint confusion

Disclaimer: I am new to working with APIs
I am working on leveraging gimbals API and am trying to figure out what exactly end points are? I realize that they link to a server, but how exactly are they used in development?
Are the endpoints used to link to specific sources of data?
I am using python(django) and it would be great to understand exactly how access and or change information on gimbals end.
PS- When looking at the gimbal api, I noticed that they have a REST api and some other mobile stuff going on. If I am building a web platform, I would only be interested in the REST API portion correct?
An endpoint in a RESTful API is generally just a URL. The URL represents some kind of resource. If it was an order processing API, the resources would be things like customers, orders, etc.
You interact with these resources by making HTTP requests of various sorts; GET if you want to know the content of a resource, POST if you want to change something, and so on. Have a look at this for basic information on REST and web APIs.
You don't need Django to interact with a RESTful API that someone else provides. All you really need is python's urllib, and maybe the json module, if they're sending the data in JSON. The REST API they provide is probably the main thing they want developers using, but if they have multiple APIs then it's hard to say which one is right for you without understanding the application better.

How can I query Google's Safebrowsing API to check a URL with Python?

I have a list of domains that I need to check for malware. Is there a way I could use Python to query Google's Safebrowsing API to get that information without the need for a database?
Google's Safe Browsing API page contains a Python reference client, take a look at that.

How would you query Picasa from a Google App Engine app? Data API or Url Fetch?

How would you query Picasa from a Google App Engine app? Data API or Url Fetch? What are the pros and cons of using either method?
[Edit]
I would like to be able to query a specific album in Picasa and list all the photos in it.
Code examples to do this in python are much appreciated.
Your question is a little off, since the Data API is exposed through RESTful URLs, so both methods are ultimately a "URL Fetch".
The Data API works quite well, though. It gives you access to nearly all the functionality of Picasa, and responses are sent back and forth in well-formed, well-documented XML. Google's documentation for the API is very good.
If you only need access to limited publicly available content (like a photostream) then you can do this at a very basic level by just fetching the feed url and parsing that... but even for that you can get the same data with more configuration options via the Data API URLs.
I'm not sure what code samples you'd like... it really depends what you actually want to do with Picasa.

Categories