Thoughts on API’s and Max

After looking at hundreds of API’s over past months – models begin to emerge:

  • Visualization: Looking at data by filtering, analysis, or factors defining movement.
  • Synthesis: producing  feeds from sources, in combination – fusion
  • Transcoding: changing one type of signal into another

Or some combination of all three.

The best tools for getting data in and out of Max:

  • curl (or variants in client libraries)
  • JSON
  • Osc
  • string parsing outside of Max
  • database tools (or data recorder in Max)
  • basic data filtering and scaling tools in Max
  • for complex networked systems: node.js

 

Mashape API’s

https://www.mashape.com

notes

 

 

 

Mashape

An API factory.

https://www.mashape.com

Happened to look at mashape.com again today. Its grown considerably over the past year and now provides access to over 1300 API’s with open source client libraries and Oauth proxies.

Mashape is an API of API’s – a layer of abstraction that standardizes how you consume API’s.

Instructions for using the API: https://www.mashape.com/docs/consume/rest

Here’s an example of a typical API call which gets the weather in San Francisco. Note I have obscured the API-key.

curl -H "X-Mashape-Authorization: YOUR-MASHAPE-KEY" "https://george-vustrey-weather.p.mashape.com/api.php?_method=getForecasts&location=San%20Francisco"

Here’s the result:

[{"day_of_week":"Wed","high":"63","low":"47","condition":"Mostly Clear"},{"day_of_week":"Thu","high":"66","low":"50","condition":"Partly Cloudy"}]

[Note] examples in tkzic/mashape

The API description pages have curl examples.

 

Installing pycurl on Mac Os

notes

update: 11/1/2014 installed version 7.19.5 using easy_install

Here’s the website: http://pycurl.sourceforge.net

It worked. Because xCode was installed?

sudo env ARCHFLAGS="-arch x86_64" /usr/bin/easy_install setuptools pycurl==7.19.0

Here are instructions, but really all I needed was the above command

http://blog.carlotorniai.net/lion-and-pycurl/

Pycurl examples: http://www.angryobjects.com/2011/10/15/http-with-python-pycurl-by-example/

Local file examples in tkzic/python-api/

There are other Python libs like request, human curl, urllib….

phantomJS

phantomJS runs outside the browser but implements enough of the DOM that you can use it for testing, rendering screenshots, running http: requests, etc.,

http://phantomjs.org/index.html

Have installed locally in: tkzic/phantomjs (binary is in the bin/ folder)

Processing, Twitter, OSC, and Max

A variation on the Twitter mood-lamp program.

note 6/2014 – this may not work due to changes in oauth

local files:

  • Processing: /documents/processing/osc_max_testing
  • Max: tkzic/max teaching examples/processing-osc

It grabs a ‘feed’ or any URL which returns a bunch of text. Then it does some analysis on the text, and using the results to send RGB data back to Max using OSC.

Raspberry-Pi FX pedal

Running in Pure Data

(update) Tried this with guitarist John Drew today (2/26/2012). We ran the guitar directly into the iMic (switched to microphone, not line) and the output of iMic into an amplifier. The R-Pi was plugged into to wifi router with an Ethernet cable, so we could use touchOsc to control the delay parameters. It sounded great.

We talked about the possibility of making this into a ‘product’. One idea would be to ditch the Osc controls and build a simple hardware interface – some encoders, switches, and LED’s. You could map everything in PD and download new patches using an ethernet cable or a usb wifi connection – or even some kind of serial/usb link.

Yesterday I programmed a simple variable delay effect in pd to run on Raspberry-Pi. Control was using touchOSC as described in previous posts. I ran the effect in mono at 32k sampling rate – and it sounded great. Also its using the Griffin iMic for sound.

Here’s the command line to set the sample rate and number of channels:

pd-extended -r 32000 -nogui -channels 1 delay-effect-osc.pd

 

Local files: