Cosm with Max

update 6/2014: Cosm is now Xively. Have not re-tested examples below. There is a working Twitter example at internet sensors projects: https://reactivemusic.net/?p=5859

original post

notes

Today I was finally able to get this working. Reading a Cosm (Pachube) feed from curl and from Max. Here is an example that works in curl: (replace API-KEY with actual key)

curl http://api.cosm.com/v2/feeds/76490/datastreams/Power.xml?key=API-KEY

You can get JSON responses by leaving off the .xml extension or replacing it with .json

Its critical to use “key=…” not “X-ApiKey=…” like in the cosm documentation, or you will get permission errors from curl and Max.

I was also able to get the Max project called “pachube report” from Nicholas Marechal to work (requires jasch and cnmat externals)

http://cycling74.com/toolbox/pachube-tools/

This patch uses the typical jit.uldl and jit.textfile objects and some regexp parsing tricks.

Next trick will be creating a feed and sending it to Cosm.

 

 

Google custom search API

notes

API for custom searches from Google…. and a method to spoof the “custom” part of it…

https://code.google.com/apis/console/

https://developers.google.com/custom-search/v1/getting_started

Use this method to build a custom search which searches the whole web…

http://stackoverflow.com/questions/4082966/google-web-search-api-deprecated-what-now

Here is an example of a search using this method with curl – note the API-KEY is removed. You will need to get an API key (see above).

curl "https://www.googleapis.com/customsearch/v1?key=API-KEY&cx=012117491442732664551:egvalbpelhq&q=lectures"

Web audio from the Soundcloud API

notes

(update) to get your client-id from Soundcloud: From your home page, select more | developers | my apps.

This looks like the easiest way to play streaming content from Soundcloud over the web, Maybe this example could be adjusted to run in Max.

http://stackoverflow.com/questions/13455956/setup-web-audio-api-source-node-from-soundcloud

Example API urls,

this one streams a track: (replace client id with real thing)

http://api.soundcloud.com/tracks/6981096/stream?client_id=CLIENT-ID

This one returns an XML file filled with tracks that can be played:

https://api.soundcloud.com/tracks?client_id=CLIENT-ID

See API reference:

http://developers.soundcloud.com/docs/api/reference#users

(update) Use /resolve to get the user id and user info, given the name – like this:

http://api.soundcloud.com/resolve.json?url=http://soundcloud.com/tkzic&client_id=CLIENT-ID

Soundcloud short-codes

This code comes from clicking the Share button on the SoundCloud clip, then using the “WordPress Code”

If you find old-style SoundCloud post on a 3rd party site, you may need to get the ’embed’ code and then add it to your post, using the html editor