a very masculine way to work with data from

npm install freebase
3 downloads in the last day
70 downloads in the last week
145 downloads in the last month

Freebase is a masculine but complicated human-curated database.

Nodejs is a straight-talkin language that takes no guff


    npm install freebase


    var freebase=require('freebase');
    freebase.description('tom cruise', {}, console.log)
    //"Tom Cruise, is an American film actor.."

Showin' off

it's built to be as flexible as possible. all methods can handle the same things:

    freebase.sentence("/en/thom_yorke", {}, console.log)//freebase link
    freebase.weblinks("thom yorke", {}, console.log)//search term
    freebase.wikipedia_categories("", {}, console.log)//weblink{"name":"thom yorke", "id":"/en/thom_yorke"}, {}, console.log)//freebase object
    freebase.notable(["/en/radiohead","thom yorke"], {}, console.log)//array of stuff

it handles many asynchronous requests responsibly, rate-limiting them to 10-at-a-time.

this is pretty clever, i'd say:

    freebase.sentence("meatloaf", {type:"/food/food"}, console.log)

In the friggin broswer


  <script src=""></script>
  <script src=""></script>
  <script src=""></script>
  <script src=""></script>
    function callback(r){
    $.freebase.description("tony hawk", {}, callback)

Writing to Freebase:

Oauth is hard, but you can do it.

register a web app at to get your Client ID and Client secret. run this 'wizard' to get your access token.

  node mqlwrite_setup.js

thats all you need to include in your request:

    freebase.add_type("/en/the_who", {type:"/music/artist", token: your_access_token})

    freebase.add_alias("/en/melanie_chisholm", {alias:"Sporty Spice", token: your_access_token})

''mqlwrite_setup.js'' will take you through the steps of authenticating and making a write to freebase. You'll need to get a new token after about 3 hours. Just run it again.

Basic methods


Books about planets:

    var query=[{
                "type":  "/astronomy/planet",
                "name":  null,
                "/book/book_subject/works": []
    freebase.mqlread(query, {}, function(r){console.log(r)})


Every Tornado, ever

      freebase.paginate(query, {max:400}, console.log)

Search API

Hockey players named 'doug'"doug",{type: "/ice_hockey/hockey_player"}, console.log)

Description API

First paragraph of a topic's wikipedia article:

     freebase.description("mike myers", {}, console.log)
     freebase.description("", {}, console.log)

Topic API

A nicely treated output of all of a topic's data:

     freebase.topic("mike myers", {}, console.log)
     freebase.topic("", {}, console.log)


The most accurate, or notable type for a topic:

     freebase.notable("canada", {}, console.log)
     -> {id:"/location/country", name:"Country"}



Which pronoun, tense, article and gender to use for this topic

    freebase.grammar("washing machine", {}, console.log)
       -> { plural: true,
            gender: null,
            article: 'a',
            pronoun: 'they',
            copula: 'are' }
    freebase.grammar(["prince harry", "miranda july"], {}, console.log)
       /* [ { plural: false,
              gender: 'male',
              article: 'a',
              pronoun: 'he',
              copula: 'is' },
            { plural: false,
              gender: 'female',
              article: 'a',
              pronoun: 'she',
              copula: 'is' } ]

Similar topics to this topic

    freebase.related("toronto", {}, function(r){
  -> /* Toronto FC
      Toronto Maple Leafs
      Toronto Argonauts
      North York
      Toronto Marlies*/


Query all of wordnet, from freebase:


sameAs weblinks for a topic, or url

    freebase.same_as_links("toronto", {}, console.log)
    freebase.same_as_links("", {}, console.log)


A common-sense search that only matches when confident:

    freebase.lookup("tom green", {}, console.log)
    freebase.lookup(["sandra bullock","suddenly susan"], {}, console.log)

First Sentence

The first sentence from a wikipedia article:

    freebase.sentence("tokyo", {}, console.log)


Graph-type queries on topics, dancing over tough values and mediators:

      freebase.graph("ubuntu", {}, console.log )
      freebase.outgoing("ubuntu", {}, console.log )
      freebase.incoming("ubuntu", {}, console.log )

Schema-agnostic queries

A list of topics in a 'is-a' type of collection:

     freebase.list("earthquakes", {}, console.log)


Translated names for topics:

     freebase.translate("radiohead", {lang:"/lang/ko"}, console.log)
     -> 라디오헤드


Encode a string for inclusion in a freebase id/key/whatever

    freebase.mql_encode("Aarno Yrjö-Koskinen")

Schema introspection

Find-out relevant information for a type or property:

     freebase.property_introspection("politician", {}, console.log)
     ->/* { domain: { name: 'Government', id: '/government' },
          is_compound_value: false,
          is_commons: 'Published',
          equivalent_topic: { name: 'Politician', id: '/en/politician' },
          topic_count: 90971,
          property_count: 0,
          included_types: [ { name: 'Person', id: '/people/person' },
                  { name: 'Topic', id: '/common/topic' } ],



Get the wikipedia link for a topic

     freebase.wikipedia_page("tony hawk", {}, console.log)
     ->// http://en.wikipedia/wiki/Tony_Hawk

Wikipedia categories

Get the wikipedia categories for this topic's article

     freebase.wikipedia_categories("tony hawk", {}, console.log)

Get the freebase topics linked-to in this topic's wikipedia article

     freebase.wikipedia_links("tony hawk", {}, console.log)
      -> /*[{ id: '/wikipedia/en/Baker_Skateboards',  name: 'Baker Skateboards' },
          { id: '/wikipedia/en/Bam_Margera', name: 'Bam Margera' },
          { id: '/wikipedia/en/Barting_Over', name: 'Barting Over' },
          { id: '/wikipedia/en/Blink-182', name: 'Blink-182' },

Get the webpages linked-to from this topic's article

     freebase.wikipedia_external_links("tony hawk", {}, console.log)
      -> /*[{ url: '',
            domain: '' },
          { url: '',
            domain: '' },



Get the lat/lng for a topic

    freebase.geolocation("calgary", {}, console.log)
    -> //{ latitude: 51.0544444444, longitude: -114.066944444 }


List topics near this geolocation

    freebase.nearby("cn tower", {type:"/food/restaurant"}, console.log)
      -> /*[{id: '/en/sneaky_dees',
           name: 'Sneaky Dee\'s',
          {id: '/en/keg_mansion',
           name: 'Keg Mansion',


List topics inside of this location



From a geo-coordinate, find out its City, Province, Country, and timezone

    freebase.place_data({lat:51.545414293637286,lng:-0.07589578628540039}, {}, console.log)

Method-list nodejs-library

  • mqlread -interface to freebase's mql api
  • lookup_id -generic info for an id
  • search -regular search api
  • url_lookup -freebase search tuned for looking up a url
  • lookup -freebase search with filters to ensure only a confident, unambiguous result
  • get_id -like freebase.lookup but satisfied with an id
  • topic -topic api
  • paginate -get all of the results to your query
  • description -get a text blurb from freebase
  • image -get a url for image href of on this topic
  • grammar -get the proper pronoun to use for a topic eg. he/she/they/it
  • same_as_links -turns a url into a freebase topic and list its same:as links
  • translate -return specific language title for a topic
  • notable -get a topic's notable type
  • sentence -get the first sentence of a topic description
  • list -get a list of topics in a type
  • place_data -from a geo-coordinate and area radius (in feet), get the town, province, country, and timezone for it
  • incoming -get any incoming data to this topic, ignoring cvt types
  • outgoing -return all outgoing links for a topic, traversing cvt types
  • graph -return all outgoing and incoming links for a topic
  • related -get similar topics to a topic
  • is_a -get a list of identifiers for a topic
  • property_lookup -lookup soft property matches, like 'birthday' vs 'date of birth'
  • question -give a topic and a property, and get a list of results
  • dig -transitive query on a specific property, maximum 3-ply
  • gallery -list of topics with images
  • wordnet -query wordnet via freebase
  • transitive -do a transitive-query, like all rivers in canada, using freebase metaschema
  • geolocation -lat/long for a topic
  • nearby -list of topics nearby a location
  • inside -list of topics inside a location
  • wikipedia_page -get a url for wikipedia based on this topic
  • dbpedia_page -get a url for dbpedia based on this topic
  • wikipedia_categories -get the wikipedia categories for a topic
  • wikipedia_links -outgoing links from this wikipedia page, converted to freebase ids
  • wikipedia_external_links -outgoing links from this wikipedia page, converted to freebase ids
  • property_introspection -common lookups for freebase property data
  • schema -common lookups for types and properties
  • drilldown -get insight into the breakdown of the topics in this type, by type and quality
  • mql_encode -quote a unicode string to turn it into a valid mql /type/key/value
  • category_list -get the freebase topics in a wikipedia category
  • wikipedia_subcategories -find the subcategories of this wikipedia category
  • rdf -RDF api
  • wikipedia_to_freebase -turn a wikipedia title or url into a freebase topic
  • add_widget -add a generic html view of a topic
  • mqlwrite -write to freebase
  • add_type -add a type to a freebase topic
  • add_alias -add a alias to a freebase topic


  • freebase.mqlread([{id:"/en/radiohead",name:null}])
  • freebase.lookup_id('/en/radiohead')
  •"bill murray")
  • freebase.url_lookup("")
  • freebase.lookup("pulp fiction")
  • freebase.get_id("/en/radiohead")
  • freebase.topic("toronto", {filter:"allproperties"})
  • freebase.paginate([{"type":"/astronomy/moon","name":null, limit:2}],{max:13})
  • freebase.description("tunisia")
  • freebase.image('toronto',{type:"/location/citytown"})
  • freebase.grammar("toronto maple leafs")
  • freebase.same_as_links("toronto maple leafs")
  • freebase.translate("toronto maple leafs", {lang:"/lang/ja"})
  • freebase.notable("toronto maple leafs")
  • freebase.sentence('john malkovich',{},console.log)
  • freebase.list("hurricanes",{}, function(r){console.log(r)})
  • freebase.place_data({lat:51.545414293637286,lng:-0.07589578628540039}, {}, console.log)
  • freebase.incoming("toronto")
  • freebase.outgoing("vancouver")
  • freebase.graph("shawshank redemption")
  • freebase.related("toronto", {}, function(r){console.log(JSON.stringify(r, null, 2));})
  • freebase.is_a("george clooney")
  • freebase.property_lookup("albums")
  • freebase.question("keanu reeves", {property:"children"})
  • freebase.dig('/en/toronto', {property:'/location/location/contains'}, function(r){ console.log(r) })
  • freebase.wordnet("charming")
  • freebase.transitive("ontario", {property:"part_of"}, function(r){ console.log(r)})
  • freebase.geolocation("cn tower")
  • freebase.nearby("cn tower", {type:"/location/location"}, console.log)
  • freebase.inside("montreal")
  • freebase.wikipedia_page('toronto')
  • freebase.dbpedia_page('toronto')
  • freebase.wikipedia_categories("Tunisia")
  • freebase.wikipedia_links("Toronto", {}, console.log)
  • freebase.wikipedia_external_links("Toronto", {}, console.log)
  • freebase.property_introspection("/government/politician/party")
  • freebase.schema("politician")
  • freebase.drilldown("/chemistry/chemical_compound",{max:400},console.log)
  • freebase.category_list("Category:Redirects_from_plurals")
  • freebase.wikipedia_subcategories("Category:Enzymes",{depth:2},function(r){console.log(JSON.stringify(r))})
  • freebase.rdf("toronto")
  • freebase.wikipedia_to_freebase("Tony Hawk")
  • freebase.documentation()


Creative Commons, MIT

npm loves you