I'm new with using third-party APIs, and I was trying to get the Review Board Web API to work in python.
However, I was confused about 3 things:
from rbtools.api.client import RBClient
client = RBClient('http://localhost:8080/')
root = client.get_root()
My first question: is http://localhost:8080/ the server that is running the ReviewBoard server? Is there some sort of test server that I can use instead of running my own?
Again, I don't have much experience with APIs so I was wondering if I needed to do some form of authentication before making these calls.
Finally, if I must set up my own Review Board server to try out the API. Would it be possible to get some code for a very simple example as to how to make the simplest POST and GET request you can think of with minimal setup if for example my server was running on http://localhost:8080/?
Reference : http://www.reviewboard.org/docs/rbtools/0.5/api/overview/
To answer your first question: the answer seems to be yes although their docs don't make it entirely clear.
Their docs say:
Here is an example of how to instantiate the client, and retrieve the Root List Resource resource:
Before the code snippet your pasted. That makes me think that the url being passed is whatever you're trying to use, e.g., you could have that set up on a networked machine called monty_python running on port 5050, then you would do:
client = RBClient('http://monty_python:5050/')
As for a test server you should check the documentation they have about their Web API.
Their examples don't seem to show any authentication being performed in the overview. If you check in other sections (e.g., Tutorial: Creating a Pull Request) you'll see them demonstrate how to authenticate and what can be done after authenticating.
As for your last question, I'm not 100% sure what you're asking, but you should probably check the docs I found for their Web API
Related
first of all, i apolagise for making such a general question, but it has been really hard to find any useful information on the web.
I would like to create a client side + server side application, which will communicate using a REST api or websockets.
However, my question is the following.
On the server side, after receiving the request from the client,
is it possible to execute a python script, which will return the intended answer, and only then returning that answer to the client?
Let's take an example.
Suppose my client app ask the user which city he is on right now.
Than, the server receives a get request with the name of that city.
Than, the server executes a python script to obtain some information about that city (lets say it searches for the weather).
Only after the script return's the info, can the server return it's answer to the client so it can be rendered.
I hope this is not marked as off topic, as i think this is a relevant general question.
I appreciate your help.
most serious Python Web frameworks have add-on that will do most of the transport / serialisation job.
Django-REST-Framework and Flask-RESTful are the kings in Python language for full stack REST server side applications.
Otherwise, for simple things and few configuration, you could consider Falcon https://falcon.readthedocs.io/en/stable/
On client side, use the "requests" package. http://docs.python-requests.org/en/master/
I have a nodejs server setup on AWS with mongoDB. I want to access the database contents using GET method. There is another application in python which needs to access this database present on AWS. I searched on the internet and came across PycURL but I am not getting how to use it exactly. How to approach with pycURL or what can be an alternate solution?
You can build your restful API that is going to handle those GET requests. You have awesome tutorial (with example that you want on bottom):
https://scotch.io/tutorials/build-a-restful-api-using-node-and-express-4
Edit: If you want phyton code for GET requests there is awesome answer here: Simple URL GET/POST function in Python
Edit 2: Example of how would this work. You first need to code your API how to handle GET request and on what route (example: http://localhost:5000/api/getUsers). Than you want to make GET request to that route using Phyton:
Example:
r = requests.get(url="http://localhost:5000/api/getUsers")
I had a similar problem a while ago, there is a tutorial here here. It can lead you towards your intended direction, the drawback may be that in the tutorial, to issue the http request (if I remember correctly), they used postman but I'm sure you can still use PyCurl.
A friend is building an API. He wants my machine learning algorithm (written in Python) to be incorporated into this API. I have heard that his API can 'remotely access' my algorithm and in this way I don't have to reveal what the code actually is.
If this is all true, can someone point me in the direction of building this. I know very little about API's!
Apologies, I'm a newbie to this!
You could upload your code to a server and create your own API for your friend's API to use.
An example of how to create a python server: http://www.acmesystems.it/python_httpserver
Basically, when you get a request, call your algorithm script and pass the data received from the request, then return an appropriate response.
For better security, you could require some identification in the request to prove that it really is your friend that's sending it. If you're afraid of your code getting leaked if the server would be hacked, you could use tools like docker.com to host the server script and your algorithm script in two different virtual machines.
I'm making a Django app with Fandjango and I'm trying to unit test it with Django's test framework. The only thing is, in order to test effectively I need a "signed_request" parameter that Facebook sends with every request. Right now I'm logging the requests my server gets from Facebook and copying + pasting the signed_request token I get, but that only works for a few hours at a time.
Is there a simple way to handle this without doing a mock of the whole Facebook API?
Thanks!
You can use Test Users:
http://developers.facebook.com/docs/test_users/
I think the access token never expires, or at less until you delete the Test User.
Well, I understand it's also possible to authenticate fully server side, using just OAuth without Javascript SDK. In that case you should be able to aquire a valid token yourself. There are, I think some libraries that can be used for that like:
http://pypi.python.org/pypi/django-social-auth/
However please note, I've never done this myself so it's more of a suggestion, than a definite answer.
EDIT
It seems like social-auth has some testing functionality that is capable of automatically signing in to a facebook account. You could probably copy the code from there.
We use a lot of of python to do much of our deployment and would be handy to connect to our TFS server to get information on iteration paths, tickets etc. I can see the webservice but unable to find any documentation. Just wondering if anyone knew of anything?
The web services are not documented by Microsoft as it is not an officially supported route to talk to TFS. The officially supported route is to use their .NET API.
In the case of your sort of application, the course of action I usually recommend is to create your own web service shim that lives on the TFS server (or another server) and uses their API to talk to the server but allows you to present the data in a nice way to your application.
Their object model simplifies the interactions a great deal (depending on what you want to do) and so it actually means less code over-all - but better tested and testable code and also you can work around things such as the NTLM auth used by the TFS web services.
Hope that helps,
Martin.
So, this question is friggin' old, but let me take a whack at it (since it keeps coming up in my google searches).
There's no officiall supported API for the on premise TFS (the MSFT hosted one has http://www.visualstudio.com/en-us/integrate/api/overview).
That said, you can always use Fiddler (http://www.telerik.com/fiddler) or something like it to inspect the calls that the web client for TFS is making to the server and do your magic to turn those into the scripts in python you want.
You'll need to run your python scripts under a service account that has TFS privs appropriate to what it is trying to do (read, update, confugure... whatever).
Since it sounds like you are just trying to read from TFS, this might be a really easy way for you to get what you want since an HTTP get to
http://yourserver/tfs/yourcollection/yourproject/_workitems#id=yourworkitemid
will hand you back (halfway) sane html payloads.
If you want lists of iterations or teams or whatever, then your service account needs to have the appropriate admin privileges and hit things like
http://yourserver/tfs/yourcollection/yourproject/_admin/_iterations
and use that response.