My answer is quite specific to the Betfair API however I would like to know how to use more APIs in general. I'm quite new to this sort of thing so don't really know how it works. I've just downloaded this package: https://github.com/jmcarp/betfair.py
My question is, how am I supposed to know the functions that come associated with it? How am I supposed to be able to know how to pull the data that I want from any given website without having any resource describing the functionality of the API?
These library is only a binding (with several errors) to Betfair APIs.
You can find documentation about this API, and therefore about this library, in Developer's web.
If you're interested in how to use Betfair APIs in Python you can take a look at Betfair's code samples.
Related
I want to perform what I think is a fairly simple task - using python I would like to obtain a list of Google Cloud Functions in a given project and want to figure out the correct library for doing so.
I'm trying to understand the myriad of repos at https://github.com/googleapis. I can see there is
https://github.com/googleapis/google-api-python-client
however at https://github.com/googleapis/google-api-python-client#other-google-api-libraries it is stated:
The maintainers of this repository recommend using Cloud Client Libraries for Python, where possible, for new code development
and following the link there leads me to
https://github.com/googleapis/google-cloud-python
at which there is a link to
https://github.com/googleapis/python-functions
This would seem to be the more appropriate library to use (pip install google-cloud-functions) for the reasons stated at https://github.com/googleapis/google-api-python-client#other-google-api-libraries.
The problem I have is that there seem to be many examples/samples that demonstrate the use of https://github.com/googleapis/google-api-python-client but less so for https://github.com/googleapis/python-functions. In fact my google-fu has failed me miserably because I can't find any examples of how I might use https://github.com/googleapis/python-functions to achieve my task (i.e. get a list of Google Cloud Functions). The API documentation at https://googleapis.dev/python/cloudfunctions/latest/index.html is somewhat helpful however it seems rather lacking in sample code. One question I'm asking myself, for example, is should I be using
google.cloud.functions_v1.services.cloud_functions_service.CloudFunctionsServiceClient
or
google.cloud.functions_v1.services.cloud_functions_service.CloudFunctionsServiceAsyncClient
or perhaps even something else.
Can someone explain how I can use CloudFunctionsServiceClient or CloudFunctionsServiceAsyncClient to get a list of functions?
Figured it out. These work
from google.cloud.functions_v1.services.cloud_functions_service import CloudFunctionsServiceAsyncClient
from google.cloud.functions_v1.types import ListFunctionsRequest
list_functions_request = ListFunctionsRequest(parent=f"projects/{project}/locations/{region}")
await CloudFunctionsServiceAsyncClient().list_functions(list_functions_request)
from google.cloud.functions_v1.services.cloud_functions_service import CloudFunctionsServiceClient
from google.cloud.functions_v1.types import ListFunctionsRequest
list_functions_request = ListFunctionsRequest(parent=f"projects/{project}/locations/{region}")
await CloudFunctionsServiceClient().list_functions(list_functions_request)
I have the problem that for a project I need to work with a framework (Python), that has a poor documentation. I know what it does since it is the back end of a running application. I also know that no framework is good if the documentation is bad and that I should prob. code it myself. But, I have a time constraint. Therefore my question is: Is there a cooking recipe on how to understand a poorly documented framework?
What I tried until now is checking some functions and identify the organizational units in the framework but I am lacking a system to do it more effectively.
If I were you, with time constaraints, and bound to use a specific framework. I'll go in the following manner:
List down the use cases I desire to implement using the framework
Identify the APIs provided by the framework that helps me implement the use cases
Prototype the usecases based on the available documentation and reading
The prototyping is not implementing the entire use case, but to identify the building blocks around the case and implementing them. e.g., If my usecase is to fetch the Students, along with their courses, and if I were using Hibernate to implement, I would prototype the database accesss, validating how easily am I able to access the database using Hibernate, or how easily I am able to get the relational data by means of joining/aggregation etc.
The prototyping will help me figure out the possible limitations/bugs in the framework. If the limitations are more of show-stoppers, I will implement the supporting APIs myself; or I can take a call to scrap out the entire framework and write one for myself; whichever makes more sense.
You may also use python debugging library: pdb. After importing it with import pdb you may set traces in the body of functions and classes pdb.set_trace(). Then it will stop the execution of the program in the line and you may look at existing variables and processes.
I am using python 3.6. I am planning to incorporate houndify in a project that I'm working on. I want to use the Houndify API to make voice requests (using only a few domains like Weather, Map, Knowledge, Wikipedia, etc.). The documentation on the page left me kind of confused, so I would really appreciate it if anyone could explain (with example code of course) how I can use the Houndify API to get results.
PS: I Don't want to use my browser in any way. All I want to use is my python code.
Have you tried looking at the documentation in the README? It has a lot of useful info. If there is a more specific question, please let me know.
https://docs.houndify.com/sdks/docs/python
I just came across googletrans python package. This package translates quite well and seems to use google translation API. To my knowledge, google translation API is not free. What googletrans doing internally for the translations? Is it legal to use googletrans?
The official documentation has information on this:
https://pypi.python.org/pypi/googletrans#how-does-this-library-work
You may wonder why this library works properly, whereas other approaches such like goslate won’t work since Google has updated its translation service recently with a ticket mechanism to prevent a lot of crawler programs.
I eventually figure out a way to generate a ticket by reverse engineering on the obfuscated and minified code used by Google to generate such token, and implemented on the top of Python. However, this could be blocked at any time.
As for the legality of this approach, this kind of stuff depends on the laws of the countries you live in, and is probably slightly off-topic.
I've read through multiple articles online, but I can't seem to find any way to properly implement my own oauth solution in python.
I'm using the tornado framework for python and I ended up converting python-oauth2's tornado solution to their most modern API with the hopes of understanding what makes up oauth2 work. I even made a contribution to the github. The biggest problem is that even after reading a large portion of the original oauth documentation, I don't understand everything. It leaves me confused when trying to make a simple oauth log-in.
A place I've looked are:
http://www.slideshare.net/leahculver/implementing-oauth -- Good slides, but since the speaker explained a lot in person of it I'm lost on some generic parts.
If you want to skip the reading, allow me to summarize:
I need a simple, yet well thought out explanation of how O-Auth 2.0 works, and how I could implement my own O-Auth 2.0.
I would like to know a good way to use python to do it.