Top-rated recipes tagged "api"http://code.activestate.com/recipes/tags/api/top/2015-11-16T14:52:17-08:00ActiveState Code Recipespygmail (can send mail) (Python) 2012-07-10T01:29:42-07:00Garretthttp://code.activestate.com/recipes/users/4181290/http://code.activestate.com/recipes/578203-pygmail-can-send-mail/ <p style="color: grey"> Python recipe 578203 by <a href="/recipes/users/4181290/">Garrett</a> (<a href="/recipes/tags/api/">api</a>, <a href="/recipes/tags/gmail/">gmail</a>, <a href="/recipes/tags/google/">google</a>, <a href="/recipes/tags/mail/">mail</a>, <a href="/recipes/tags/pop/">pop</a>, <a href="/recipes/tags/python/">python</a>). </p> <p>Can both send and receive mail, as well as do other things.</p> How to use Python to convert a web page to PDF with a POST request to SelectPdf Online API and save it on the disk (Python) 2015-11-16T14:52:17-08:00SelectPdfhttp://code.activestate.com/recipes/users/4193129/http://code.activestate.com/recipes/579126-how-to-use-python-to-convert-a-web-page-to-pdf-wit/ <p style="color: grey"> Python recipe 579126 by <a href="/recipes/users/4193129/">SelectPdf</a> (<a href="/recipes/tags/api/">api</a>, <a href="/recipes/tags/converter/">converter</a>, <a href="/recipes/tags/htmltopdf/">htmltopdf</a>, <a href="/recipes/tags/pdf/">pdf</a>, <a href="/recipes/tags/selectpdf/">selectpdf</a>). </p> <p>This code converts an url to pdf in Python using SelectPdf HTML To PDF REST API through a POST request. The parameters are JSON encoded. The content is saved into a file on the disk.</p> Search for oranges with the wikipedia Python library (Python) 2015-11-03T18:52:55-08:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/579121-search-for-oranges-with-the-wikipedia-python-libra/ <p style="color: grey"> Python recipe 579121 by <a href="/recipes/users/4173351/">Vasudev Ram</a> (<a href="/recipes/tags/api/">api</a>, <a href="/recipes/tags/library/">library</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/retrieving/">retrieving</a>, <a href="/recipes/tags/web/">web</a>, <a href="/recipes/tags/wikipedia/">wikipedia</a>). </p> <p>The wikipedia Python library (available on PyPI) is a wrapper for the official Wikipedia API. The library is higher level and easier to use than the API, though for limited functionality of the API. It can be used to easily do basic access of Wikipedia pages, which could be useful for many educational, reference and other purposes. This recipe shows the basic use of the wikipedia library, by using it to search for information about oranges.</p> Add function to Python's __builtin__ module through C API - makefile (Text) 2015-10-16T12:11:36-07:00airweenhttp://code.activestate.com/recipes/users/4192997/http://code.activestate.com/recipes/579111-add-function-to-pythons-__builtin__-module-through/ <p style="color: grey"> Text recipe 579111 by <a href="/recipes/users/4192997/">airween</a> (<a href="/recipes/tags/api/">api</a>, <a href="/recipes/tags/c/">c</a>, <a href="/recipes/tags/makefile/">makefile</a>, <a href="/recipes/tags/python/">python</a>). </p> <p>Makefile for add function to __builtin__ module through C API.</p> <p>C source is here:</p> <p><a href="https://code.activestate.com/recipes/579110-add-function-to-__builtin__-module-through-c-api/" rel="nofollow">https://code.activestate.com/recipes/579110-add-function-to-__builtin__-module-through-c-api/</a></p> <p>Python script is here:</p> <p><a href="https://code.activestate.com/recipes/579112-add-function-to-__builtin__-module-through-c-api-c/" rel="nofollow">https://code.activestate.com/recipes/579112-add-function-to-__builtin__-module-through-c-api-c/</a></p> Add function to Python's __builtin__ module through C API (C) 2015-10-16T12:11:58-07:00airweenhttp://code.activestate.com/recipes/users/4192997/http://code.activestate.com/recipes/579110-add-function-to-pythons-__builtin__-module-through/ <p style="color: grey"> C recipe 579110 by <a href="/recipes/users/4192997/">airween</a> (<a href="/recipes/tags/api/">api</a>, <a href="/recipes/tags/builtins/">builtins</a>, <a href="/recipes/tags/c/">c</a>, <a href="/recipes/tags/exten/">exten</a>, <a href="/recipes/tags/python/">python</a>). </p> <p>Add function to __builtin__ module through C API</p> <p>Sometimes it need to embedding a Python script to a C code, and it references to a function, which also provided by the same C code. Then you have to import the module, as you defined in your C code.</p> <p>But this import would be skipped, if you add your function to your __builtin__ module. In Python3 (3.5), there is the PyModule_AddFunctions() function, but in the previous versions, you can make it like this snippet.</p> <p>See these recipes:</p> <p>Makefile: <a href="https://code.activestate.com/recipes/579111-add-function-to-__builtin__-module-through-c-api-c/" rel="nofollow">https://code.activestate.com/recipes/579111-add-function-to-__builtin__-module-through-c-api-c/</a></p> <p>Python script: <a href="https://code.activestate.com/recipes/579112-add-function-to-__builtin__-module-through-c-api-c/" rel="nofollow">https://code.activestate.com/recipes/579112-add-function-to-__builtin__-module-through-c-api-c/</a></p> Fluent API method decorator (Python) 2015-07-08T13:20:58-07:00Oscar Byrnehttp://code.activestate.com/recipes/users/4192487/http://code.activestate.com/recipes/579078-fluent-api-method-decorator/ <p style="color: grey"> Python recipe 579078 by <a href="/recipes/users/4192487/">Oscar Byrne</a> (<a href="/recipes/tags/api/">api</a>, <a href="/recipes/tags/decorator/">decorator</a>, <a href="/recipes/tags/decorators/">decorators</a>, <a href="/recipes/tags/fluent/">fluent</a>, <a href="/recipes/tags/interface/">interface</a>). </p> <p>A decorator for producing robust fluent API interfaces by returning a copy of self</p> Convert HTML to PDF with the PDFcrowd API (Python) 2015-03-07T20:22:54-08:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/579032-convert-html-to-pdf-with-the-pdfcrowd-api/ <p style="color: grey"> Python recipe 579032 by <a href="/recipes/users/4173351/">Vasudev Ram</a> (<a href="/recipes/tags/api/">api</a>, <a href="/recipes/tags/html/">html</a>, <a href="/recipes/tags/pdf/">pdf</a>, <a href="/recipes/tags/pdfcrowd/">pdfcrowd</a>). </p> <p>This recipe shows how to use Python and the PDFcrowd API to convert HTML content to PDF. The HTML input can come from a remote URL, a local HTML file, or a string containing HTML.</p> Easy way to use Graph Facebook API without ad-hoc libraries (Ruby) 2012-11-20T14:14:27-08:00Filippo Squillacehttp://code.activestate.com/recipes/users/4174931/http://code.activestate.com/recipes/578343-easy-way-to-use-graph-facebook-api-without-ad-hoc-/ <p style="color: grey"> Ruby recipe 578343 by <a href="/recipes/users/4174931/">Filippo Squillace</a> (<a href="/recipes/tags/api/">api</a>, <a href="/recipes/tags/facebook/">facebook</a>, <a href="/recipes/tags/http/">http</a>, <a href="/recipes/tags/ruby/">ruby</a>). </p> <p>I was painfully lokking for a simple function that allow easily make GET or POST requests in Ruby without using complex libraries such as Koala for accessing to the Facebook Graph. At the end I gave up and did it by myself, so the function fb_api, based on net/http, is able to make GET or POST requests (depending if the request is for retrieving information of the graph or is for changing the graph such as post feed etc.). It returns a dict from a JSON data structure.</p> <p>This might be useful for your facebook app ;)</p> Check PC Power (Python) 2011-08-28T12:25:49-07:00Frank Larkinhttp://code.activestate.com/recipes/users/4179117/http://code.activestate.com/recipes/577861-check-pc-power/ <p style="color: grey"> Python recipe 577861 by <a href="/recipes/users/4179117/">Frank Larkin</a> (<a href="/recipes/tags/api/">api</a>, <a href="/recipes/tags/computer/">computer</a>, <a href="/recipes/tags/passing/">passing</a>, <a href="/recipes/tags/pointers/">pointers</a>, <a href="/recipes/tags/power/">power</a>, <a href="/recipes/tags/widows/">widows</a>). </p> <p>Call windows API GetSystemPowerStatus to determine if the AC power is on or off. Great example of calling Windows APIs using Ptyhon.</p> using `from somename.api import *` when somename is a single module (Python) 2011-08-12T20:24:11-07:00Ethan Furmanhttp://code.activestate.com/recipes/users/4177684/http://code.activestate.com/recipes/577839-using-from-somenameapi-import-when-somename-is-a-s/ <p style="color: grey"> Python recipe 577839 by <a href="/recipes/users/4177684/">Ethan Furman</a> (<a href="/recipes/tags/api/">api</a>, <a href="/recipes/tags/import/">import</a>, <a href="/recipes/tags/modules/">modules</a>, <a href="/recipes/tags/__all__/">__all__</a>). </p> <p>Allow a module to export a subset of __all__, so a user can do <code>from module.api import *</code></p> (gopytranslte) script google translator (Python) 2011-04-14T17:17:12-07:00namakukingkonghttp://code.activestate.com/recipes/users/4176734/http://code.activestate.com/recipes/577556-gopytranslte-script-google-translator/ <p style="color: grey"> Python recipe 577556 by <a href="/recipes/users/4176734/">namakukingkong</a> (<a href="/recipes/tags/api/">api</a>, <a href="/recipes/tags/google/">google</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/python3/">python3</a>, <a href="/recipes/tags/script/">script</a>, <a href="/recipes/tags/translate/">translate</a>, <a href="/recipes/tags/translator/">translator</a>). Revision 3. </p> <p>hehehehe..... Very little code for study.....</p> csc prototype to arduino board with python API. part II (Python) 2010-12-26T12:20:48-08:00cheeng shu chinhttp://code.activestate.com/recipes/users/163970/http://code.activestate.com/recipes/577521-csc-prototype-to-arduino-board-with-python-api-par/ <p style="color: grey"> Python recipe 577521 by <a href="/recipes/users/163970/">cheeng shu chin</a> (<a href="/recipes/tags/api/">api</a>, <a href="/recipes/tags/arduino/">arduino</a>, <a href="/recipes/tags/c/">c</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/serial/">serial</a>). Revision 2. </p> <p>This is the Python API for my arduino uno board. this is base on what i posted in <a href="http://code.activestate.com/recipes/577520-csc-prototype-to-arduino-board-with-python-api-par/?in=user-163970">Part I</a> .. I didn't spend time to comments it... I'll do it once free soon. Please study it and extend it and share among open source members especially in python... :)</p> <p>The file name is "cscarduino.py"</p> <p>if you facing "Pyserial Invalid Handle" issue in your 64bit windows 7 server, Please refer to this:</p> <ol> <li><a href="http://permalink.gmane.org/gmane.comp.python.tutor/67030">link1</a></li> <li><a href="http://www.mail-archive.com/tutor@python.org/msg46974.html">link2</a></li> </ol> csc prototype to arduino board with python API. part I (C) 2010-12-26T12:14:33-08:00cheeng shu chinhttp://code.activestate.com/recipes/users/163970/http://code.activestate.com/recipes/577520-csc-prototype-to-arduino-board-with-python-api-par/ <p style="color: grey"> C recipe 577520 by <a href="/recipes/users/163970/">cheeng shu chin</a> (<a href="/recipes/tags/api/">api</a>, <a href="/recipes/tags/arduino/">arduino</a>, <a href="/recipes/tags/c/">c</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/serial/">serial</a>). Revision 2. </p> <p>Few day ago, i'm try out arduino UNO robotic board. found it not that easy to use (C &lt;--> Python). I wrote a arduino UNO prototype to serial API, which can interface to any programming Language. as long as the programming Language can interface to virtual serial port and using serial API, this recipe can be use... Requirement:</p> <p>Upload this recipes to arduino uno with my prototype code (name "csc.pde" as below)</p> <p>Base concept:</p> <ol> <li>wait from serial reply "?" and ready for read</li> <li>pass function name as string to arduino uno</li> <li>pass all argument as string to arduino uno</li> <li>read result as string from arduino uno</li> </ol> <p>Can easy extend it to support:</p> <ol> <li>python API(open source and i like most) in part II</li> <li>other arduino board</li> <li>Bluetooth with serial interface</li> <li>any PC can control the arduino board easily via your prefer Language.</li> <li>interrupt </li> </ol> <p>Future add-on:</p> <ol> <li>Json string passing to arduino</li> <li>Json Reply from arduino</li> <li>thread base design</li> <li>Interrupt direct call</li> </ol> <p>Please study it and extend it and share among open source members especially in python... :)</p> <p>Next <a href="http://code.activestate.com/recipes/577521-csc-prototype-to-arduino-board-with-python-api-par/">Part II</a></p> Wordze.com API bindings (Python) 2010-01-21T21:24:39-08:00Sergei Lebedevhttp://code.activestate.com/recipes/users/4172845/http://code.activestate.com/recipes/577018-wordzecom-api-bindings/ <p style="color: grey"> Python recipe 577018 by <a href="/recipes/users/4172845/">Sergei Lebedev</a> (<a href="/recipes/tags/api/">api</a>, <a href="/recipes/tags/bindings/">bindings</a>, <a href="/recipes/tags/wordze/">wordze</a>, <a href="/recipes/tags/wordze_com/">wordze_com</a>). Revision 3. </p> <p>Just in case anyone would need the bindings, here's a very basic implementation. For some reasons, <a href="http://wordze.com" rel="nofollow">wordze.com</a> has very strict API usage limitations, so to use this efficiently, you'll probably need to cache every request-response. </p> <p>Any comments and/or corrections are welcome. :) </p> Send and receive SMS messages using TextMagic (Python) 2015-05-01T19:03:46-07:00Dawie Strausshttp://code.activestate.com/recipes/users/4170915/http://code.activestate.com/recipes/576826-send-and-receive-sms-messages-using-textmagic/ <p style="color: grey"> Python recipe 576826 by <a href="/recipes/users/4170915/">Dawie Strauss</a> (<a href="/recipes/tags/api/">api</a>, <a href="/recipes/tags/sms/">sms</a>, <a href="/recipes/tags/smsgateway/">smsgateway</a>). Revision 12. </p> <p><a href="http://www.textmagic.com">TextMagic</a> is a provider of SMS services. Their SMS gateway is accessible via an HTTPS API. A convenient wrapper for this API is <a href="http://pypi.python.org/pypi/PyTextMagicSMS/">PyTextMagicSMS</a>. Full documentation and source code is available on the project's <a href="https://github.com/dfstrauss/textmagic-sms-api-python">website</a>.</p> <p>In order to use the service, you need to register at <a href="http://www.textmagic.com/" rel="nofollow">http://www.textmagic.com/</a> and obtain an API password (different from your login password) at <a href="https://www.textmagic.com/app/wt/account/api/cmd/password" rel="nofollow">https://www.textmagic.com/app/wt/account/api/cmd/password</a></p> A modification of the blogger exemple for adding category (Python) 2008-08-20T21:08:06-07:00bussiere bussierehttp://code.activestate.com/recipes/users/4050557/http://code.activestate.com/recipes/576441-a-modification-of-the-blogger-exemple-for-adding-c/ <p style="color: grey"> Python recipe 576441 by <a href="/recipes/users/4050557/">bussiere bussiere</a> (<a href="/recipes/tags/api/">api</a>, <a href="/recipes/tags/blog/">blog</a>, <a href="/recipes/tags/blogger/">blogger</a>, <a href="/recipes/tags/blogspot/">blogspot</a>, <a href="/recipes/tags/google/">google</a>, <a href="/recipes/tags/tag/">tag</a>, <a href="/recipes/tags/tags/">tags</a>). Revision 3. </p> <p>Just because the exemple from google didn't add the category thanks from : <a href="http://coolnamehere.wordpress.com/2008/01/02/adding-categories-to-the-python-blogger-client/" rel="nofollow">http://coolnamehere.wordpress.com/2008/01/02/adding-categories-to-the-python-blogger-client/</a></p> URL shortner using Bit.ly api (Python) 2012-09-14T08:37:39-07:00aamir hussainhttp://code.activestate.com/recipes/users/4178272/http://code.activestate.com/recipes/578263-url-shortner-using-bitly-api/ <p style="color: grey"> Python recipe 578263 by <a href="/recipes/users/4178272/">aamir hussain</a> (<a href="/recipes/tags/api/">api</a>, <a href="/recipes/tags/bitly/">bitly</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/urlshortner/">urlshortner</a>). </p> <p>URL shortner using Bit.ly api</p>