David Janes' Code Weblog

November 12, 2008

Work API Teaser II – Praized API

demo,ideas,python,search,semantic web,work · David Janes · 6:46 pm ·

Implementing a merchant search using the Praized API took about 10 minutes (mainly finding the right documentation), using my WORK framework:

class PraizedMerchants(bm_api.API):
    """See: http://code.google.com/p/praized/wiki/A_Second_Tutorial_Search"""

    _uri_base = "http://api.praized.com/apitribe/merchants.xml"
    _meta_path = "community"
    _item_path = "merchants.merchant"
    _page_max_path = 'pagination.page_count'
    _page_max = -1

    def __init__(self, api_key, slug = "apitribe", **ad):
        bm_api.API.__init__(self, api_key = api_key, **ad)

        self._uri_base = "http://api.praized.com/%s/merchants.xml" % slug

    def CustomizePageURI(self, page_index):
        if page_index > 1:
            return  "page=%s" % page_index

Partially hardcoding ‘apitribe’ as a ‘community slug’ is probably a bad idea. Anyhoo, here’s how you call it…

api_key = os.environ["PRAIZED_APIKEY"]
api = PraizedMerchants(api_key = api_key, slug = "david-janess-code")
api.SearchOn(
    q = "Bistro",
    l = "Toronto",
)
for item in api.IterItems():
    print json.dumps(item, indent = 1)

… and a set if results, somewhat edited below. I’ll have to figure out what that “permalink” is all about (I’ve edited it to shorten it)  … it could be something neat, but I haven’t quite grasped all the ins and outs of what Praized wants to accomplish as a business.

{
 "@Index": 0,
 "@Page": 1,
 "short_url": "http://przd.com/zAU-7",
 "pid": "af5bebd604f3d1517a8113e0a2e8cc58",
 "updated_at": "2008-10-04T20:49:34Z",
 "phone": "(416) 585-7896",
 "permalink":
   ".../praized/places/ca/ontario/toronto/coffee-supreme-bistro?l=Toronto&q=Bistro",
 "name": "Coffee Supreme Bistro",
 "created_at": "2008-10-04T20:49:34Z",
 "location": {
  "city": {
   "name": "Toronto"
  },
  "country": {
   "code": "CA",
   "name_fr": "Canada",
   "name": "Canada"
  },
  "longitude": "-79.384071",
  "regions": {
   "province": "Ontario"
  },
  "postal_code": "M5J 1T1",
  "latitude": "43.646347",
  "street_address": "40 University Avenue"
 }
}

October 28, 2008

Amazon's OpenSearch: mostly useless

search,semantic web · David Janes · 8:28 am ·

As part of a broader project I’m working on, I decided to see if there’s a way I could easily get search results from the web in machine readable fashion. One project to facilitate this is Amazon/A9′s OpenSearch. Alas, it’s useless:

  • No big web search provider has signed on to provide machine readable results. Including A9/Alexa! A9 will aggregate search results from different OpenSearch providers for you, it just won’t let you use Alexa’s results elsewhere (search for Alexa on that page)
  • even if you were to buy into the search aggregation approach, many (most?) of sources are dead now. A little pruning wouldn’t hurt here guys! (search for IMDB on that page)

I wouldn’t be tempted to be offer my search results in OpenSearch format, because who’s going to use it after I put in the work? And if all that’s available as search sources are mostly broken C and D-list sites, well who cares? It’s a fringe benefit, but not one that I’m looking for and nor likely are you. You’d think that Amazon would use Alexa search results in OpenSearch to “prime the pump”, but I guess being the Nth placed web search service is good enough for them.

Note that there’s a great argument for simply marking up search results with hAtom and use rel=next to navigate to the next page of results, but that’s a topic for another day,

If I have any of my facts wrong here, I apologize in advance: the documentation kind of sucks. I’m also sure there’s some difference between A9, Alexa and Amazon – I really just don’t have the time to work it out.

Further reading

Powered by WordPress

Switch to our mobile site