Skip to content

A Twitter bot that tweets info about pedestrian and bike crashes in cities

Notifications You must be signed in to change notification settings

An-dy1/pedestrian-and-bike-crashes

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Twitter bot that tweets Bicyclist and Pedestrian related crashes, using Citizen data.

Tweet screenshot

Run

npm install to fetch and install dependencies.

To run: node index.js --location cityNameOne, where cityNameOne is the name of the city you want to fetch and tweet data for (see keys section for more information).

Keys file

To use, create a keys.js file with the following format for each city you want to fetch and tweet data for:

module.exports = {
    cityNameOne: {
        consumer_key: 'consumer_key',
        consumer_secret: 'consumer_secret',
        access_token: 'access_token',
        access_token_secret: 'access_token_secret',
        lowerLatitude: 'lowerLatitude',
        lowerLongitude: 'lowerLongitude',
        upperLatitude: 'upperLatitude',
        upperLongitude: 'upperLongitude',
        timeZone: 'America/New_York',
    },
    cityNameTwo: {
        consumer_key: 'consumer_key',
        consumer_secret: 'consumer_secret',
        access_token: 'access_token',
        access_token_secret: 'access_token_secret',
        lowerLatitude: 'lowerLatitude',
        lowerLongitude: 'lowerLongitude',
        upperLatitude: 'upperLatitude',
        upperLongitude: 'upperLongitude',
        timeZone: 'America/Los_Angeles',
    },
    ...
};

To get the consumer_key, consumer_secret, access_token, and access_token_secret values, you'll need to sign up for a Twitter Developer account.

To get the lowerLatitude, lowerLongitude, upperLatitude, and upperLongitude values, you'll need to go to the Citizen explore page. Open up the developer tools in your browser, go to the network tab, and select the city you want to see incidents for. Select the trending API call and the latitude and longitude values are the parameters in the URL.

The timeZone value is used for converting incident times (Citizen stores them in UTC) to the city's local time. The timeZone value for your city can be found here - use the value in the TZ database name column. If your city isn't listed just use the closest major city (ex. for Philadelphia use America/New_York).

About

A Twitter bot that tweets info about pedestrian and bike crashes in cities

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%