About
This is the Factual-supported Node.js driver for Factual's public API.
Install
$ npm install factual-api
Get Started
Include this driver in your projects:
var Factual = ;var factual = 'YOUR_KEY' 'YOUR_SECRET';
If you don't have a Factual API account yet, it's free and easy to get one.
Read
Doc: http://developer.factual.com/api-docs/#Read
// Full-text search:factual; // Row filters:factual; factual; factual; // Geo filter:factual; // Get a row by factual id:factual;
Schema
Doc: http://developer.factual.com/api-docs/#Schema
factual;
Facets
Doc: http://developer.factual.com/api-docs/#Facets
// show top 5 cities that have more than 20 Starbucks in Californiafactual;
Resolve
Doc: http://developer.factual.com/api-docs/#Resolve
// resovle from name and address infofactual; // resolve from name and geo locationfactual;
Match
Doc: http://developer.factual.com/api-docs/#Match Match the data with Factual's, but only return the matched Factual ID:
factual;
Crosswalk
Doc: http://developer.factual.com/places-crosswalk/ Query with factual id, and only show entites from Yelp:
factual;
Or query with an entity from Foursquare:
factual;
Multi
Doc: http://developer.factual.com/api-docs/#Multi Query read and facets in one request:
var readQuery = factual;var facetsQuery = factual;factual;
Note that sub-responses in multi's response object might be factual api's error responses.
Reverse Geocoder
Doc: http://developer.factual.com/api-docs/#Geocode Get the nearest valid address from a latitude and longitude
factual;
Geopulse
Doc: http://developer.factual.com/api-docs/#Geopulse Get geographic attributes from a latitude and longitude
factual;
World Geographies
World Geographies contains administrative geographies (states, counties, countries), natural geographies (rivers, oceans, continents), and assorted geographic miscallaney. This resource is intended to complement the Global Places and add utility to any geo-related content.
factual;
Submit
http://developer.factual.com/api-docs/#Submit NOTICE: At the current time, this API call is ONLY compatible with places-v3. Please see the the migration page for more details.
Doc:factual;
Diffs
http://developer.factual.com/api-docs/#Diffs NOTICE: Server support for this feature is still under development. You are getting a preview of how this driver will support the feature. If you try using this feature now, you may not get a successful response. We will remove this notice once the feature is fully supported.
Doc:// callback to handle all the diffsvar now = ;var start = now - 7*24*3600*1000; // last weekfactual; // callback to handle each difffactual;
Flag
Doc: http://developer.factual.com/api-docs/#Flag NOTICE: At the current time, this API call is ONLY compatible with places-v3. Please see the the migration page for more details.
factual;
Clear
Doc: http://developer.factual.com/api-docs/#Clear Clear existing attributes in an entity
factual;
Boost
Doc: http://developer.factual.com/api-docs/#Boost
factual;
Error Handling
The error object is the first argument of the callback functions, it will be null if no errors.
Debug Mode
To see detailed debug information at runtime, you can turn on Debug Mode:
// start debug modefactual; // run your querie(s) // stop debug modefactual;
Debug Mode will output useful information about what's going on, including the request sent to Factual and the response from Factual, outputting to stdout and stderr.
Change base url
If you want to send the requests to other hosts/port instead of "http://api.v3.factual.com:80", you can set it manually:
// 1.set globallyfactual;// back to defaultfactual;// 2. set for each requestfactual;
Use custom timeout
You can set the request timeout(in milliseconds) now:
// set the timeout as 1 secondfactual;// clear the custom timeout settingfactual;
You will get [Error: socket hang up] for custom timeout errors.
Where to Get Help
If you think you've identified a specific bug in this driver, please file an issue in the github repo. Please be as specific as you can, including:
- What you did to surface the bug
- What you expected to happen
- What actually happened
- Detailed stack trace and/or line numbers
If you are having any other kind of issue, such as unexpected data or strange behaviour from Factual's API (or you're just not sure WHAT'S going on), please contact us through GetSatisfaction.