npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

event-core

v0.1.7

Published

Search Facebook events by location and proximity.

Downloads

6

Readme

Search Facebook events by location, distance and search terms

As Facebook has discontinued the FQL query API for all apps created after 2014-04-30, it has gotten much more complicated to get public Facebook events by passing a location.

This implementation uses regular Facebook Graph API calls in a three-step approach to get the events:

  1. Search for places in the radius of the passed coordinate and distance (/search?type=place&q={query}&center={coordinate}&distance={distance})
  2. Use the places to query for their events in parallel (/?ids={id1},{id2},{id3},...)
  3. Unify, filter and sort the results from the parallel calls and return them to the client

###Known limitations

  • The Graph API has some "instabilities" with search results. It's possible that the amount of results returned can vary between calls within seconds
  • The /search endpoint "magically" limits the number of results, independent from the distance used (larger distance doesn't guarantee more results)
  • Rate limiting will apply, but I experienced no call blocks within a reasonable amount of service requests. Be aware that the way this application works, there are potentially hundreds of (counted) Graph API calls per request to /events.

Installation

As NPM package

The module can be installed via

npm install facebook-events-by-location-core --save

Git

To clone the repository, use

git clone https://github.com/tobilg/facebook-events-by-location-core.git

Usage

The basic usage pattern of this module is the following:

var EventSearch = require("facebook-events-by-location-core");

var es = new EventSearch({
    "lat": 40.710803,
    "lng": -73.964040
});

es.search().then(function (events) {
    console.log(JSON.stringify(events));
}).catch(function (error) {
    console.error(JSON.stringify(error));
});

Access Tokens

The above example expects that the FEBL_ACCESS_TOKEN environment variable is set to a valid App Access Token. Otherwise, you need to specify the accessToken parameter with the request.

Parameters

Mandatory parameters are the following:

  • lat: The latitude of the position/coordinate the events shall be returned for
  • lng: The longitude of the position/coordinate the events shall be returned for

Non-mandatory parameters

  • query: The term(s) on which you want to narrow down your location search (this only filters the places, not the events itself!).
  • accessToken: The App Access Token to be used for the requests to the Graph API.
  • distance: The distance in meters (it makes sense to use smaller distances, like max. 2500). Default is 100.
  • sort: The results can be sorted by time, distance, venue or popularity. If omitted, the events will be returned in the order they were received from the Graph API.
  • version: The version of the Graph API to use. Default is v2.7.
  • since: The start of the range to filter results. Format is Unix timestamp or strtotime data value, as accepted by FB Graph API.
  • until: The end of the range to filter results.

Sample output (shortened)

{
	"events": [{
        "id": "913797995409682",
        "name": "Tom Misch at Baby's All Right - Brooklyn, NY",
        "type": "public",
        "coverPicture": "https://scontent.xx.fbcdn.net/t31.0-8/q84/s720x720/13640856_1107200012651875_5165020515859707325_o.jpg",
        "profilePicture": "https://scontent.xx.fbcdn.net/v/t1.0-0/c0.63.200.200/p200x200/13716257_1107200012651875_5165020515859707325_n.jpg?oh=840e5aa7e4c2a882d170934c06909b0f&oe=5852B03A",
        "description": "Communion Music Presents\nTom Misch\n\nBaby's All Right - Saturday November 5\n\n**SOLD OUT**",
        "distance": "103",
        "startTime": "2016-11-05T19:00:00-0400",
        "endTime": "2016-11-05T23:59:00-0400",
        "timeFromNow": 6864534,
        "stats": {
            "attending": 118,
            "declined": 0,
            "maybe": 193,
            "noreply": 259
        },
        "venue": {
            "id": "460616340718401",
            "name": "Baby's All Right",
            "about": "[email protected]",
            "emails": ["[email protected]"],
            "coverPicture": "https://scontent.xx.fbcdn.net/v/t1.0-9/10649483_874901589289872_3338946923837693978_n.jpg?oh=f514ac7ee60c2a7e58158179686bef28&oe=584392F3",
            "profilePicture": "https://scontent.xx.fbcdn.net/v/t1.0-1/p200x200/1480734_642185745894792_5820988503650852577_n.png?oh=0ba9012178c119defae67c932d0841bd&oe=5847FD2D",
            "location": {
                "city": "Brooklyn",
                "country": "United States",
                "latitude": 40.709985,
                "longitude": -73.963476,
                "state": "NY",
                "street": "146 Broadway",
                "zip": "11211"
            }
        }
    },
	... 
	],
	"metadata": {
		"venues": 1,
		"venuesWithEvents": 1,
		"events": 4
	}
}