GithubHelp home page GithubHelp logo

jamiehowarth0 / nationbuilderclient Goto Github PK

View Code? Open in Web Editor NEW

This project forked from techroanoke/nationbuilderclient

0.0 1.0 0.0 17 KB

A C# client for NationBuilder

Batchfile 0.19% C# 99.81%

nationbuilderclient's Introduction

NationBuilderClient

A C# client for NationBuilder, http://nationbuilder.com/ This provides friendly C# wrappers for the NationBuilder REST API, as defined at http://nationbuilder.com/api_documentation

It includes handling for people, tags, lists, surveys, and precincts. It also includes helpers for doing OAuth login.

See Samples/Program.cs for example usage.

To create a client from a slug and access token

  // Enter your slug and access token. 
  string slug = "<your slug here>";
  string accessToken = "<your access token here>";

  NBClient client = new NBClient(slug, accessToken);

To print all the lists in the your Nation

        private static async Task PrintLists(NBClient client)
        {
            Console.WriteLine("Lists:");
            NBList[] lists = await client.GetListsAsync();
            foreach (NBList list in lists)
            {
                Console.WriteLine("(ListId={0}): {1} ({2} records)", list.id, list.name, list.count);
            }
            Console.WriteLine();
        }

To view the tags and query by tag:

        private static async Task ReadTagsAsync(NBClient client)
        {
            Console.WriteLine("All tags:");
            NBTag[] tags = await client.GetAllTags();
            foreach (var x in tags.Take(10))
            {
                Console.WriteLine(x);
            }

            // Query by tag. 
            var tag = tags[0];
            Console.WriteLine("People with tag '{0}'", tags);
            var people = await client.GetPeopleWithTagAsync(tag);
            foreach (NBPerson person in people.Take(10))
            {
                Console.WriteLine("  {0} {1}", person.first_name, person.last_name);
            }
            Console.WriteLine();
        }

nationbuilderclient's People

Contributors

mikestall avatar

Watchers

Jamie Howarth 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.