Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm in dire need of getting started with REST JSON API, possibly with python.
Already purchased the subscription to use the API. How can I make a REST request?
Below is an excerpt from the documentation.
REST Request
https://smartmover.melissadata.net/v3/WEB/SmartMover/doSmartMover
?t={Transmission Reference}
&id={License Key}
&jobid={Job ID}
&pafid={PAF ID}
&act={Actions}
&cols={Columns}
&opt={Options}
&List={List Name}
&comp={Company}
&full={Name Full}
&first={Name First}
&Middle={Name Middle}
&Namepre={Name Prefix}
&Namesfx={Name Suffix}
&last={Name Last}
&u={Urbanization}
&a1={Address Line 1}
&a2={Address Line 2}
&ste={Suite}
&pmb={Private Mailbox}
&city={City}
&state={State}
&postal={Postal Code}
&plus4={Plus4}
&ctry={Country}
&format={Format}
Thanks for any help!!!!
The question is a bit vague, and opinion-based, but I'll give you some directions to seek:
First of all, just get some grasp of HTTP and REST API concepts overall. Wiki may be a good starting point
If your looking for non-programmatic HTTP API client, take a look at httpie. The good thins is that it gives you a glimpse of what's going on lower-ish level, while maintaining really good balance of detail vs simple interface (not grapic interface, tho). As a bonus, its written in python
For programmatic use (this is probably what you looking for), I suggest using requests library. It has awesome interface, and IMO it's standard de-facto in modern python. Easy to use, easy to understand how to use it with your API, handles a lot of routine stuff for you, easy to subclass/inherit.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I am writing a wrapper function for a web API right now and the API expects the date to be input in a particular format (YYYY-MM-DD). I am wondering how to notify the wrapper user if the the input format is incorrect?
My thoughts:
Let the API itself take care of it and simply return what the API
returns
This takes care of any future changes in the API
Write a handler in the wrapper and if the input is incorrect, then
simply return the HTTP error code 400 (Bad Request).
The users often have a restriction of number of API requests per day and this would help them from wasting them because of invalid input.
EDIT
As pointed out in the comments, the decision depends on my take on maintenance. Can you also tell me is the general good practice or should one look at these situations on case by case basis?
Remember:
A wrapper function is a subroutine in a software library or a computer program whose main purpose is to call a second subroutine or a system call with little or no additional computation.
As found on Wikipedia.
Therefore I suggest you doing the first thing, letting the API handle it. Whenever I use a wrapper, I only ever want to look at the Documentation of the actual API, not the wrapper. It also seems a lot more intuitive to me.
Good luck :)
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
In reference towards me question, how would one be able to input data and retrieve data from various websites (not using an API)?
Is there a module that searches or acts like a human for purposes as in searching along applicably given fields; in effort to (as said before) retrieve data?
Sorry if I'm making my question hard to follow along; though if so, here's an example of what I am trying to accomplish:
Directing an AI towards a specific website.
Inputting data into the search field.
Then finally, retrieving said data after previously ran processes.
I'm fairly new to the section or field in manipulating websites via APIs or various (unknown) code; therefore, sorry if I missed anything!
You can use
mechanize,
BeautifulSoup,
Urllib,
Urllib2,
modules in Python. What I suggest you is use mechanize module. It is like scraping website through python program. More over simply a browser through python code.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I'm new to web development and going to make a website which responses with data received from request to web-service(facebook for e.g.) and how to choose what is more useful here:
nodejs has an callback model which allows not to wait while gathering data for user from other services (but i've broken my fingers and my brain after trying to make a kind of class in javascript with inheritance and the whole server drops after unhandled error in script)
python is very convinient in working with diff. kinds of data, it's more convinient for me, former C++ developer
yesterday i've read about twisted python that also uses callbacks
Help me please to choose what to use, better - performance, simple code
The callback model might make your code more verbose but WAIT! there is a solution! Check out
waitfor.
Anyway, if it's a personal project then no one is forcing you to use node.js for webapp development.You should go with what makes you more comfortable. If you like developing in python then go for it! :)
why don't you try django; it uses python (which you said is more convenient) and is also very commonly used for web development.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
There is a lot going on in web frameworks - they can take an age to learn.
So, what is it I am missing when I say that WSGI defines pretty much all we need to respond to a request. If I overload the environ dict I can store almost all I need, so what am I gaining from a framework?
You can certainly write a web application using only WSGI, but at some point you're going to have to solve the following problems:
How do I handle different url requests?
How do I parse form data?
How do I render a response?
How do I support sessions?
How do I persist data?
etc, etc, etc...
Each web framework solves some (or all) of these problems. Yes, you could design and implement solutions yourself, but web frameworks contain solutions that other people have found work very well for them. So that's what you get from a framework: a bunch of suggestions for how to solve common problems when writing web apps.
Finally, it's easy to be overwhelmed by the number of choices for web frameworks, but if you just learn one, others will be much easier to understand. I would recommend learning either django or a more minimalist framework like flask. Other frameworks are pretty similar to these two, and you'll be able to pick them up easily.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I would like to learn how to use jsonp with python. I googled around for any useful tutorial. However, it seems that there are no so much resources up there.
Thus I would like to ask here if anybody knows any tutorial, API that I can use, or any best practices.
Thank you.
Do you mean supporting the generation of JSOP output with a Python-powered API or website?
That's pretty easy to support. Say your API at /some/resource.json already outputs some JSON encoded data (say, in the code it's a return json.dumps(dict(a='foo'))).
To support JSONP all you have to do is accept a callback parameter (say /some/resource.json&callback=some_func). Now, if you get this parameter, instead of returning just the json serialized data, you wrap it in a function call:
d = json.dumps(dict(a='foo'))
return 'some_func(' + d + ');'
That way, calling web-client code can simply auto insert script tags in its DOM to magically load your javascript 'function'. Make sense?