Skip to main content

API Developers Forum

We're thrilled to see all the great development going on with the NationBuilder API, and want to open this forum up for public feedback, helps and hints, questions and more. This resource is curated by the NationBuilder API Team - our goal is developers helping developers, so we definitely want to hear from you. You can also use the tags to rank posts. Thanks!

Please check your e-mail for a link to activate your account.
Sort by

Permissions on API

I would like to be able to do more with the API than just searches, such as creating and updating people. Currently this is possible with the test token, but not an OAuth token.

A global permission level for the API would be enough, along with a flag on users to specify if they can OAuth and use the API's extended permissions. That way I could grant fine-grained permissions to the API, then give just a few users access to the API through OAuth. I would really like to stop using the test token because that's terrible security long-term.

completed

Grigory,

You can limit access to staffers by toggling their permission set. If you navigate through the control panel to Settings > Permission sets > select the permission set you want to limit authentication for > and scroll to the bottom you will see the option under API. Toggle this to 'no' and then assign that permission set to staffers you want to limit app authentication for.

 

Official response from

1 reaction

Primary Address Create/Update through API

I would like to update a person's primary address through the API, and also be able to create a new person with an address. 

completed

Grigory,

Being able to update primary address via the API has been confirmed but does not have a set timeline on when it will be added to the people API. With regard to creating a new person with only an address, you must supply at least a first and last name, an email address, or a phone number.

 

Official response from

3 reactions

Is Theme Sync dead?

Used it quite a bit 2 years ago to great effect. Now it loops between choose site page and back to login page. Choosing a site seems to log me back out.

Still working for other people?

started

Jedd,

ThemeSync still works and I recommend uninstalling/reinstalling it to get past the hiccup you're experiencing. Also, we have started working on a different solution that utilizes a Dropbox integration.

Official response from

4 reactions

I am trying to set up my paypal account....what is an API signature?

completed

An API signature is an API credential assigned by PayPal. 

Official response from

2 reactions

Extend tags API to include tag counts

Right now, the only way to find out how many people are tagged with a specific tag in your nation, via the API, is to call the people method, which returns a paginated list of people with that tag. You then have to go through every page, incrementing the counter for every person. Needless to say this involves a fair few API calls for large tags.

There's already a tag index where you can see a list of tags - we just need that index to include a number too.

considering

This is something we will consider but does not have a timeline at the moment.

However we are paying close attention to the most popular suggestions so please share and encourage others to follow and comment!

Official response from

4 reactions

Webhooks: Support for Events

Hello,

I'm suggesting support for webhooks for changes (creation, update, deletion) to events administered within NationBuilder.

My use case is I'm building a web app to index political events around the country. If groups, who are NationBuilder customers, could connect to it and submit new events and updates, that would have a huge impact on adoption, which would in turn impact event attendance for those customers, and subsequent volunteering, contributions and other engagement from the supporters. I can imagine other third party sites might be interested in this functionality too.

I'm a developer myself, so I'm happy to submit a pull request or sample code if that would be useful, but I'd be curious to hear NationBuilder's thoughts on adding this feature.

Thank you!

Jon

2 reactions

Incomplete API for blog posts

Issue :

The API for blog posts (https://apiexplorer.nationbuilder.com/nationbuilder#Blog-Posts) is only serving content excerpt and not the all page html content.

2 reactions

PHP vs. C++

The folks who are building our store and automation are redoing some of the programing they did  in PHP in C++  because it runs faster and can handle a lot more data.  Would doing that help with the speed of loading into your system?  I don't know how it is programed now, but thought I'd pass that along.

completed

Generally speaking, performance of API access is mostly limited by network connectivity and I/O time so it’s unlikely that you will see a major performance difference accessing our APIs using PHP or C++.

Official response from

2 reactions

Expose more functionality via API

We have tried to integrate our donation management system with NationBuilder and have had some limitations in your api preventing this. It would be nice to have NationBuilder expose via API:

  1. A way for an unfulfilled pledge (i.e. non paid pledge) to be created into a nation
  2. Get a list of unpaid pledges
  3. submit payment for a pledge and mark the pledge as fulfilled

This would allow us support NationBuilder as a possible persistence backend in our application

http://nationbuilder.com/suggest?utm_campaign=public_issues&utm_medium=email&utm_source=3dna

completed

Hakeen,

This is currently possible with our existing APIs as described below:

1. You can use the people API / push endpoint and the donations_pledged_amount_in_cents resource to create an unpaid pledge. 

2. This is rather complicated, but you could use the people API / show endpoint to get a full representation of a record including pledge amount and then cross-reference this using the donation API / index endpoint for whether a pledge_id exists. Records with a pledge amount but without a pledge_id will be everyone in the nation who has an unpaid pledge.

3. This is possible using our donation API/pledge_id resource. This resource is the id of the pledge a donation submitted via the donation API fulfills.

Official response from

2 reactions

How to check if someone is logged in via the api

Hi,

I've got a simple PHP app running on our site but I want to know who is using it and ensure obviously only the right people can use it.

Can someone point me to the docs on doing just that please?

Mat

 

Add your reaction

Marital status field on import API

When running an import through the import API, if a single marital status field is wrong (eg is 'Inferred Married' or similar rather than 'Married' or 'M'), it rejects the entire import with a status 400 bad request. Is it possible to silently ignore than like with other fields?

considering

This is something we will consider but does not have a timeline at the moment.

However we are paying close attention to the most popular suggestions so please share and encourage others to follow and comment!

Official response from

1 reaction

Has anyone used Formidable API (WordPress) with the Nationbuilder API?

I am working with a group that has a WordPress  website with the Formidable plug-in. They want to create forms in WordPress and have the information passed to Nationbuilder in real time. Does anyone have knowledge or experience in setting up the Formidable API to connect with the Nationbuilder API?

2 reactions

Getting the code with PHP

I think there is a problem with the quickstart for PHP.

Someone with access to the Nation's resources will have to visit that url in a browser, accept the application and retrieve the authorization code from the page url. That page url will look something like:

GET http://yourapp.example.com/oauth_callback?code=123456abcdef

Use the code to generate an access token:

But it doesn't make sense, this a program, not a person accessing a browser and getting the code. How can I get the code 

using PHP, not someone visiting the url in a browser?

 

Anthony

completed

The process this is describing is the admin workflow for authenticating the application with the nation. We have example code for authenticating with PHP in our API documentation.

Official response from

2 reactions

Accessing blog posts of edited blog

Hello,

When editing a blog, the blog posts themselves are not deleted and can still be viewed on the site by their URL and found via search.

Add your reaction

Encoding of API responses

The headers in responses from the API specify "Content-type: application/json", but don't specify an encoding. As other aspects of the system use utf-8, I'm assuming that it should be "Content-type: application/json; charset=utf-8".  Am I right? If so it would be helpful if this could be fixed or documented.

 

completed

Andrew,

You are correct and can use "Content-Type: application/json; Charset=UTF-8".

Official response from

1 reaction

Accessing blog posts of deleted blog

Hello,

When deleting a blog, the blog posts themselves are not deleted and can still be viewed on the site by their URL and found via search. How do we use the NationBuilder API to access blog posts of a deleted blog? All of the blog post methods require a blog ID.

not planned

Jonathan,

Thanks for bringing this to our attention. After testing this it is clear that deleting the blog post is difficult after deleting the blog if you don't have the blog_id because the ability to index blog pages goes away when you delete the page. It is possible to delete the posts through the control panel. To do this, please go to your nation's control panel and select the Website tab and then toggle the drop down for 'page type' to 'blog post.' Once here you should see all blog posts including the posts that were subpages of the blog page you deleted and can choose to delete the posts here.

Official response from

4 reactions

How we can use tracking_code_slug on Leaderboards?

I want to limit Leaderboard entries with respect to the tracking_code_slug in donations.
How to use this variable in Leaderboard template?

Add your reaction

Help of C# api sample code

Hi

Can you please advise what the reference of EndPointProvider and ServiceRequest<PersonContainer>, it shows error (both object are not existing) when I build the PesonSerivce.cs file.

publicPerson CreatePerson(Person person)

{

string endpoint = EndPointProvider.GetCreatePersonEndPoint();

var container = newPersonContainer(person);

var request = new ServiceRequest<PersonContainer>(endpoint, container);

PersonContainer result = PostWithResult<PersonContainer, PersonContainer>(request);

return result.Person;

}

 

And same issue happens on the Service.cs,  Task<HttpResponseMessage>,

ConfigProvider and MediaTypeWithQualityHeaderValue("application/json") cannot be found.

Such as code below

 

 

privatevoid SendRequest<T>(ServiceRequest<T> request, Func<HttpClient, Task<HttpResponseMessage>> sendFunc)

whereT : class

{

using (var client = newHttpClient())

{

client.Timeout = ConfigProvider.ServiceTimeout;

client.DefaultRequestHeaders.Accept.Clear();

client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

Task<HttpResponseMessage> postTask = sendFunc(client);

Task.WaitAll(postTask);

HttpResponseMessage response = postTask.Result;

if (response.IsSuccessStatusCode)

{

return;

}

Task<string> responseTask = response.Content.ReadAsStringAsync();

Task.WaitAll(responseTask);

string responseText = responseTask.Result;

string payloadString = request.Payload != null ? JsonConvert.SerializeObject(request.Payload) : null;

Logger.Error("Error sending {0} to: {1}. Response: {2}", payloadString, request.Endpoint, responseText);

thrownewInvalidOperationException("API call failed.");

}

}

 

 

regards

Stanley

Add your reaction

JSON/jQuery formatting for People create?

Hello and apologies for the noob question. Using jQuery for API calls and I just can't seem to make a request that contains acceptable JSON data for the api. Using something like this:

var rq = $.ajax({
method: "POST",
url: "https://[...].nationbuilder.com/api/v1/people?access_token=[...]",
accepts: "application/json",
contentType: "application/json",
data: JSON.stringify(
{ person: {
email: "[email protected]",
last_name: "Smith",
first_name: "Bob",
sex: "M",
signup_type: 0,
employer: "Dexter Labs",
party: "P"
} }
)
})

Return message is always "I can only talk JSON..."

completed

Hi Jedd,

I would suggest using an online tool such as the JSON Formatter/Validator, which gave some helpful prompts to adjust the request above to the following raw JSON:

 
   "person": 
      "email":"[email protected]",
      "last_name":"Smith",
      "first_name":"Bob",
      "sex":"M",
      "signup_type":0,
      "employer":"Dexter Labs",
      "party":"P"
   }
}

It may also be helpful to consult the docs for the JSON.stringify method you're using for how that is transforming the data you're sending it.

Hope this helps, and happy coding!


Official response from

2 reactions

API exerpt, thumbnail and featured content sliders

Hi,

How can I add the excerpt, thumbnail and a featured content slider via the api?

Cheers,

Mat

1 reaction

Exports "Create/Run" endpoint won't work

I can't seem to get the Exports Create/Run endpoint working through either the API explorer or actual calls from code. I am adding the following json to the request body:

{
    "export": {
        "context": "people"
    }
}

and adding the list_id to the query string but all I get in response is HTTP 406 (Not acceptable). Am I doing something wrong?

Additionally, the API explorer doesn't allow you to provide a value of the list_id parameter for this endpoint.

completed

Hi Kevin,

Thank you for letting us know about this - there's was an issue with the API Explorer that has now been resolved.

The url for the request for an export should be POST https://slug.nationbuilder.com/api/v1/lists/:list_id/exports with the request body as you had specified in JSON.

Ex: 

curl -X POST -H "Content-type: application/json" 'https://<slug>.nationbuilder.com/api/v1/lists/<list_id>/exports?access_token=<access_token>' --data '{"export":{"context":"people"}}'


Best,

Alex

Official response from

3 reactions

When will API and web hooks be updated to reflect the new paths?

What is the status on webhooks/api access to paths?

11 reactions

New "upgrade" killing off the Developers?

According to http://nationbuilder.com/feature_comparison , it looks like the Developer API is only going to be available on plans starting at a thousand dollars a month now?  This effectively kills off the developer market entirely.

Was this intended?  The Developer API was one of the main reasons I came to NationBuilder, and I keep my community hosted here.  It's also been a huge reason for me to promote NationBuilder as an option amongst other non-profits, but the new pricing effectively destroys the potential of usage by most non-profits... 

Is there any form of the API being left in the lower tiered plans?

 

-Reed

 

completed

It is true that nations on the Leader and Organization package will not have access to the API. Nations on any package can still install apps and hire a certified developer from our developer directory to build an integration with other systems using our API. The only restriction for nations on the Leader and Organization package is for them accessing the API to build a custom integration using non-certified developers.

Becoming a certified developer or publishing an app in our app directory will allow you to work with any customer regardless of the pricing package they are on. To become a certified developer please fill out this form and we'll be in touch shortly. To publish an app to our app directory please contact me directly at [email protected].

Official response from

18 reactions

Building Custom Applications

Hey all .... reasonably new to NB, but long time web native.

At first glance of custom NB development I can only see reference to API authentications.  
I can see here, a reference to PHP "Tools" Anatomy of a NationBuilder app ... which is cool, as most of our work is LAMP based.

I have clients with custom "apps" that we would look to be embedding into the workflows and profile/ACL access methods of NationBuilder ... which would require the applications to be run within the NB framework/site structure.  This is application around career profiling, strength/weakness profiling, career training, life direction, etc ... specifically about people who have lost direction, at risk, or needing direction/life planning after certain events in life.

I guess what we'd be looking to do is build something like a NB functional area, such as core "events/survey/petitions" type thing as a functional addon/app.  Is this something that can be plugged in, installed, maintained ... when it is not core?

Embedding custom apps and functionality into platforms like Drupal/Joomla/WP is easy enough ... but having trouble finding how/where we can do this type of thing in NB.  Hoping someone can point me in the right direction.

Thanks in advance,

Max Lynam :)

Add your reaction

Issue with Private Notes via API

We are making use of the /people/:person/notes API endpoint to log some notes about people, however in NationBuilder the note is coming "from" the person who created the app inside nation builder. For example "John Doe posted a private note about Jane Doe".
We dont want it to come from John Doe as he did not make the note, it came from the API.

a) How can we make the note come from the nation or simply be there and not be from someone?
or
b) How can we tell it to make the note from a "generic" person we created in the nation ?

5 reactions

Accessing People on non-Directory Pages

I'm wondering if there is a way to configure a non-directory page (for example, a donations page) so that it has access to the People profiles through Liquid. Are all pages on a Nation's website configured so that they have access to the entire Nationbuilder database through Liquid, or do I need to make requests separately, through a separately implemented Javascript API if I want to access Nationbuilder people on a donation page?

not planned

Hey Lachlan, our site object has drops available for recent_supporters and random_supporters, but no drops that give full access to the people database. It's worth mentioning that the Directory pagetype only pulls from supporters, and is generally scoped to supporters with a specific tag. Unfortunately, there is no secure way to do this via the API as ours is meant for server-side code and there isn't a way to hide the access token client-side.

Official response from

3 reactions

Using API in PHP for email sign up form; how to activate/verify email address?

I've got a script working nicely where a user visiting a WordPress site can fill out their name and email address, check the opt-in box, and sign up to a list on NationBuilder. But I can't seem to find any information on how to have NationBuilder send a verification email or double opt-in message to the new user to confirm that the email is valid and they do really truly want to be on this list. How would we go about this using the API?

4 reactions

People api custom search

I am trying to search people based on other criteria than those provided by the search api. (support_level to be more specific) I can't seem to find a way to do that. My nation has about 400 000 people in it. Even if I narrow using the tags, I still have to sort through around 80000 people.  With a limit of 100 results per page, that's still 800 requests. Am I missing something? I tried using the custom_value field of the search endpoint but it doesn't seem to work with preset fields in the database like support_level. 

Thanks

Add your reaction

Unsubscribe Handling?

What's the best way to unsubscribe a person from the email list? Update the Person record and set an unsubscribed_at timestamp?

Can we receive a webhook when unsubscribes happen on your side? Or does person.updated already trigger for unsubscribes?

We're looking at propagating unsubscribes that happen on our system into NationBuilder. 

Nathan 

completed

Hi Nathan,

Using the API, the way of unsubscribing a person would be to change the email_opt_in value on a person resource to false, this would set the unsubscribed_at timestamp automatically to the time at which the change is pushed back to the profile in the nation.

Additionally, while there isn't a webhook for unsubscribes, the person_changed webhook will fire when someone's email preferences change in the nation.


I hope this helps,

Alex

Official response from

1 reaction

Payment Processing

We are exploring a scenario where payment processing would be done outside NationBuilder payment processor.

Any API functionality that can alert our system of a donation without processing it.

Kind Regards 

Add your reaction

People Search Api not showing results

 

hi,

I am new to using the nation builder api. I have added multiple contacts to my account and trying to search on them using various fields. But I am unable to get the results.

The following person exists in my contacts and i can get it when I use first_name and last_name in the search parameters, but If i use city or state i am unable to get results.

https://slugName.nationbuilder.com/api/v1/people/search?first_name=Jennifer&last_name=Rolle

primary_address: {

address1: "address"
address2: "3"
address3: null
city: "Fort Lauderdale"
state: "FL"
country_code: "US"
zip: "33311"
}
but if i use https://slugName.nationbuilder.com/api/v1/people/search?state=FL
i get no results
{
results: [0]
next: null
prev: null
}

 

completed

Hi Ella,

There was an issue with people#search where instead of searching the primary address, the home address of people was searched instead (people in NationBuilder can have up to 7 different addresses, more on that here - including how to set primary address for a person). This explains why you weren't seeing results through the API as your nation didn't have any home addresses that matched what you were searching for.

A fix was pushed out today, and searching city or state through people#search should now return results that match based on the primary addresses of folks in your nation.

Best,

Alex

Official response from

5 reactions

Returning people including expiration date

I'm working on an integration tool to create newsletter labels for our members. It seems I can get the GET /api/v1/people endpoint fine but not with the expiration date, as this returns an abbreviated member. I'm aware there is the /person/:id endpoint, but this would affect acceptable usage to have to call this for every user in the database (currently >1000).

Given memberships are such a big thing with the types of organisation on NationBuilder, I would think this is going to be a popular endpoint if added.  What we really needed is an endpoint that returns an abbreviated member record that also includes an expiration date.  At the moment it seems that what we want to accomplish isn't possible, particularly with the rate limiting currently in place.

For what it's worth in our previous system we pulled all records from a local database to determine the labels and which need renewal forms to be added.

A less ideal alternative would be a variant to /match or /search with a parameter with an expiration date range option.

4 reactions

Person API "created_at

For the PUSH endpoint of the PERSON api, will updated persons have the "created_at" property overwritten with the time that the update took place -- the same value also appearing in "updated_at"?  (for whatever reasons, this is the case in the API docs

completed

Hey Lilia,

The people#push endpoint allows you to update or create a person in your nation. When the request creates a person, the two fields you mentioned (created_at and updated_at) will be the same. In other cases where the request matches an existing person in your nation, the updated_at field will change (along with the other data passed in the request) on the person's profile.

I hope this helps clear things up!

Official response from

2 reactions

Person could_vote_status values are Inconsistent with On-line Documentation

The documentation of "Person Resource" at <http://nationbuilder.com/people_api> says

could_vote_status - boolean indicating if this person could vote in an election or not, derived from their election-related IDs

However, the examples, and, actual, server responses contain values null, -1,  1.

This seems to be a nullable integer. Trying to parse it as a boolean can cause your application to fail.

What are the possible values, and their meanings for this field?

Thanks,

Pav

2 reactions

API based credential checking?

hi all,

I'm designing an app which will have 2 parts;

  • a (server-side) token request service which has an access token to operate the NB API
  • a browser based app which will needs to use the NB API, so requires its own access token

I'd like to restrict the usage of the browser app to people with current credentials in my NB site, and potentially tagged in a certain way. Something like this;

  1. user posts credentials (userid, pwd-hash) to my token request service
  2. my service uses the NB API to check the user's credentials (userid, pwd-hash) 
  3. if good, the service requests a new access token for the user and returns it to the user's browser ... this is the reply to the request (1)
  4. user's browser app can now operate the API and do something useful.

Is there an API call to support (2) ??

Is this a reasonable pattern?

Nick

3 reactions

[API] Relationships between People to People/Organizations are not available

We are not able to add relationships either between people with each other or with an organization through the API provided by NationBuilder.

We are trying to add various types of users on NationBuilder, such as adding a student and a school. However, we want to assign that a particular student has the relation "Student At" his/her school. This assignment is not available as the current API version does not support the endpoint "Relationships".

Is there a solution to set these relationships?

Thanks

Mohamed Hisham

21 reactions

User information is not updated same email (WordPress - API - NationBuilder)

We are not able to update existing user Account (user is registerred only with email address) with additional information (like First Name, Last Name, phone) that will be submitted later using the same email address...

We are inplemented custom form on WordPress website and already integrated with NationBuilder (API based). All new users, who submitted via our form are registerred in NationBuilder. BUT if user will send via form new personal info with the identical email as was registerred - NationBuilder will not update user info (error: user already exist). User's Password in NationBuilder was not created or edited (so do not think this is the issue).

We tried 2 variants http://apiexplorer.nationbuilder.com/nationbuilder#People  , but both are failed.
See below.

Look forward to hearinf any comments.

Regards

---------

Variant 1

$dataBuilder = array (

'person' => array(
'email' => "","last_name" => "Smith", "first_name" =>"Bob" 
));

$token = '3b30b97feea94bf20c31f83eb787d7d86b8a373561925d5b007a6bb6b79848d0';
$url = add_query_arg(
array('access_token' => $token), 'https://beekeepersandbox.nationbuilder.com/api/v1/people/push'
);
$json_data = json_encode($dataBuilder);
$ch = curl_init($url);

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, '10');
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: $token", "Content-Type: application/json", "Accept: application/json"));
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data);
$result = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$content_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
if ($curl_error = curl_error($ch)) {
throw new Exception($curl_error, Exception::CURL_ERROR);
} else {
$json_decode = json_decode($result, true);
}
curl_close($ch);
$response = array(
'result' => (null === $json_decode) ? $result : $json_decode,
'code' => $http_code,
'content_type' => $content_type
);

We get empty result without errors.

 

Variant 2

$params = array(
'person' => array(
'email' => '','home_address' => array('country' => 'Germany', 'zip' => '66666' ))
);

$header = array('Authorization:' => $token,'Content-Type:' => 'application/json', 'Accept:' => 'application/json');
$response = $client->fetch($baseApiUrl . '/api/v1/people/push?access_token=myaccesstoken', $params, 'PUT',$header);
print_r($response);

i get the following response

Array
(
[result] => Array
(
[code] => missing_parameters
[message] => Missing Parameters.
[parameters] => Array
(
[0] => person
)

[inner_error] => Array
(
[name] => Api::Error::MissingParameters
[message] => Missing parameters: person
)
)
[code] => 400
[content_type] => application/json
)

1 reaction

Comments API

Any chance we’ll see access to the Page Comments API in the near future? I’d love to be able to leverage Disqus comments without sacrificing the value of the native comment platform (i.e., creating new signup records and appending comment information to existing ones).

3 reactions

Survey API endpoints

Is the survey aspect of the API live?  When I try to update survey questions I get this response back: 

{
   
"code":"not_found",
   
"message":"Record not found"
}

I am using this json to pass it through:

{
"survey_response": {
"survey_id": 1,
"person_id": 2,
"question_responses": [{
"question_id": 2,
"response": 1
}, {
"question_id": 1,
"response": "yes"
}, {
"question_id": 3,
"response": "cool"
}]
}
}

10 reactions

blog post images

Hi,

Reading here: http://nationbuilder.com/blog_post_page_variables

Is it possible to show a blog posts attachments or feature silder (I can see those options aren't listed...)?

Is it possible to check if a page has a specific attachment?

Thanks,

 

Mat

 

completed

Hi Matt,

Sure - via Liquid it's possible to see the attachments for any particular page using page_attachments (more information on that here). There are also some additional variables for featured content sliders, which are called a bit differently.

Using the API, this is possible through the page attachments endpoint where you could view a single (or all) attachments on a page, or upload your own. Featured content sliders, on the other hand, aren't currently accessible through our endpoints.

Hope this helps!

Alex

Official response from

2 reactions

Does access_token expire? oauth/token response includes "expires_in" attribute

In some tests I noticed that responses from /oauth/token have the attribute "expires_in". This attribute isn't included in the quick start guide example response, and a colleague found an article about access_tokens no longer expiring. Anyone have more information about this topic?

completed

D B - What Alex is referring to in his previous comment is that tokens no longer expire until they are manually revoked through the nation's control panel.

Official response from

9 reactions

"name" parameter to /people/push API does not get saved

When creating a new user via the API /people/push if only "name" is passed, nation builder ignores it (instead of parsing out first name/last name).

If I pass first_name/last_name then it does grab that, however the system were we are getting the data from does NOT have a first/last name - and I dont want to build the logic to guess at seperating them from the user input.

Also, its ignoring twitter_id
And I also found that you need to push "twitter_login" as the twitter handle, where the documenation says "twitter_name" as the handle.

1 reaction

Using the API from "pure" Javascript

I'd like to call into the API from within some JavaScript code, purely running in the browser.

How can you authenticate safely if you want to use the API purely on a client side application?  Many APIs allow you to restrict a token to a single or set of referrers (so they only work on sites under certain domains).  Is there a similar mechanism within NationBuilder's API?

 

14 reactions

Sending email blasts using the API

Hi,

I was wondering if it's possible to send email blasts through the NationBuilder API.

We currently assemble our newsletter in our CMS (Drupal), and then send out the generated HTML page using our mailing list provider's API, from within Drupal. Is this possible with the NationBuilder API? And if not, is this something you are planning to add to the API?

Thanks!

1 reaction

Webhhok support

I would like to run a PHP webhook from a 3rd party payment portal on a NationBuilder site. The payment is sent to the payment provider from the NationBuilder site and I would like to send custom emails when the payment is approved. I have already written and tested the script on my own server.

Is this possible on NationBuilder websites?

2 reactions

Pagination on the API returns different results in production vs. testing environments

It seems that the API returns different responses in my testing and the production environments, specifically for the case of the survey_responses endpoint. I don't get the pagination variables in the production environment, and, as a result, my code breaks. 
In my app, I need the pagination information in order to loop through the all of the survey responses for a client and gather all the relevant responses based on user ID. It's a major part of the app as they're expecting a lot of responses and pagination will eventually become an issue, so I need more than the max 1000 that is set by the API.
So, part of my method asks: 
client.call(:survey_responses, :index, survey_id: 47, per_page: 1000)

When I run this method locally, I get the pagination information up at the top (page, total_pages, per_page, total); the same result as in NB's API Explorer. When I run it in my production environment... Heroku, nada.

The interesting thing is that the "next" and "prev" hash show up both locally and in production. So, I also tried to use them as markers to loop, making API calls until the "next" hash returns nil, spelling the end of the pagination. Again, this works perfectly fine locally. However, in production this actually made it worse because it resulted in an infinite loop which crashed the app. It seems the API never actually returns next as "nil", but instead keeps returning a unique API URL to the "next" set: "/api/v1/survey_responses?__nonce=[omitted]&__token=[omitted]&page=1448&per_page=100&survey_id=47"

I'm trying to figure if it's NationBuilder's API, my app or Heroku that are causing this discrepancy. Am reaching out to Heroku as well and testing the app itself.

I wanted to see if anyone else has come across this and solved it?

5 reactions

PHP Failing to work...

Very descriptive, I know. But after running through the PHP quickstart http://nationbuilder.com/api_documentation  I get so far as obtaining the code, but when trying to get an access token it returns a 400 bad request error with the message: "Your browser sent a request that this server could not understand."

This is all code provided by nationbuilder, so what went wrong? Is there anything I need to know before starting? I set up an app. It is set to public. It currently says "in review" for status but I see no mention of this mattering in the docs. 

This is the code:

require('src/OAuth2/Client.php');
require('src/OAuth2/GrantType/IGrantType.php');
require('src/OAuth2/GrantType/AuthorizationCode.php');


$client_id = 'xxxxxx'; //obviously i use the real id and key
$key = 'xxxxxx';

$client = new OAuth2\Client($client_id, $key);

$redirectUrl = 'http://www.some-site.com/oauth.php';

$authorizeUrl = 'https://xxx.nationbuilder.com/oauth/authorize';
/*

running this gives the code below.
$authUrl = $client->getAuthenticationUrl($authorizeUrl, $redirectUrl);

echo $authUrl;

*/
$code = 'xxxxxx';

$accessTokenUrl = 'https://xxx.nationbuilder.com/oauth/token';
$params = array('code' => $code, 'redirect_uri' => $redirectUrl);
$response = $client->getAccessToken($accessTokenUrl, 'authorization_code', $params);
$token = $response['result']['access_token'];
print_r($response);

 

Did I miss something? Or does someone have a more complete example to try?

3 reactions

Allow a read-only subset of the API to be called without authentication

We need to pull in data via AJAX to our NationBuilder site to populate it dynamically (we are hacking tags to link Events to Pages).  However, being client-side we can't implement OAuth but we don't need to POST any data.

Add your reaction

New turf cutter not displaying geocoded people

I added people to my nation using the People API.

 

Checking their records shows they've been geocoded (mostly to an exact address). The only address for each person is the Registered Address, which is their Primary Address.

 

After adding to a list and viewing on the NEW turf cutter there are no people to view. Furthermore, when using the legacy turf cutter I _can_ see the people there.

 

Can you please explain to me what is going wrong? I'm concerned with relying on a legacy feature for our future use.

 

Many thanks,

Andre

Add your reaction

Mark Donation as Refunded

After a credit card donation has been added as successful to a person, is there a method to update it to indicate that it was refunded or voided.

I tried setting canceled_at and failed_at to a date.  I also tried removing the value for succeeded_at (which leads to some unusual and misleading error messages)

The only method I have seen that "sort of" works, is to delete the donation.  But then there is no record of it at all.  Is deletion the only option I have?

1 reaction