Giter Club home page Giter Club logo

get-enciv-info's Introduction

getEncivInfo API

This is a thin API to get information from the bpinfo server using a socket.io connection

Usage

To add this to package.json, edit the file and add this to the dependencies:

  "dependencies": {
      ...
    "get-enciv-info": "git+https://github.com/EnCiv/get-enciv-info.git"
    ...
  }

Two environment variables are required:

ENCIV_API_KEY="a long private api key"
ENCIV_API_URL="https://enciv-api-server-name.com"

APIs

stage_videos: Get the candidate conversation viewer urls:

const getEncivInfo=require('get-enciv-info');

getEncivInfo("stage_videos","2020",stage_videos=>{
    if(!stage_videos) console.error("error getting stage_videos");
    console.info("getEncivInfo:", stage_videos);
})

this output is a list of objects that look like this:

 [ { stage: '65520',
    viewer_url:
     'https://undebate-dd.herokuapp.com/country:us/state:il/congress:u-s-house-illinois-district-14/stage:primary/party:republican-party/2020-03-17' },
  { stage: '65521',
    viewer_url:
     'https://undebate-dd.herokuapp.com/country:us/state:il/congress:u-s-house-illinois-district-14/stage:primary/party:democratic-party/2020-03-17' },
     ...
 ]

candidate_videos: Get candidate recorder urls:

getEncivInfo("candidate_videos","2020",candidate_videos=>{
    if(!candidate_videos) console.error("error getting candidate_videos");
    console.info("getEncivInfo:", candidate_videos);
})

this output is a list of objects that look like this:

[ { candidate_stage_result: '67248',
    recorder_url:
     'https://undebate-dd.herokuapp.com/country:us/state:il/congress:u-s-house-illinois-district-14/stage:primary/party:republican-party/2020-03-17-recorder-xxxxxxxxxxx',
    recorded: false },
  { candidate_stage_result: '67250',
    recorder_url:
     'https://undebate-dd.herokuapp.com/country:us/state:il/congress:u-s-house-illinois-district-14/stage:primary/party:republican-party/2020-03-17-recorder-xxxxxxxxxxx',
    recorded: false },
    ...
]

disconnect: close the connection

The socket.io connection to the server is persistent. If you ever want to disconnect from the server, for example so the demo program will exit, use the disconnect API

getEncivInfo("disconnect")

To test this, you can git clone the repo, set the environment variables, and run the demo

node demo

get-enciv-info's People

Contributors

ddfridley avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.