# JSON data to determine if Patron Member is a Creator's Patreon or not

**URL:** <https://www.patreondevelopers.com/t/json-data-to-determine-if-patron-member-is-a-creators-patreon-or-not/760>\
**Category:** Friendly Help\
**Created:** [June 26, 2018, 12:28pm UTC](https://www.patreondevelopers.com/t/json-data-to-determine-if-patron-member-is-a-creators-patreon-or-not/760 "2018-06-26T12:28:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![preston](https://avatars.discourse-cdn.com/v4/letter/p/a587f6/32.png) [@preston](https://www.patreondevelopers.com/u/preston)\
**Post date:** [June 26, 2018, 12:28pm UTC](https://www.patreondevelopers.com/t/json-data-to-determine-if-patron-member-is-a-creators-patreon-or-not/760/1 "2018-06-26T12:28:42Z")

</div>

Hi,

Below is the sample json file for the Patron profile returned by the API:  
{  
“data”: {  
“attributes”: {  
“about”: null,  
“created”: “2017-10-20T21:36:23+00:00”,  
“discord\_id”: null,  
“email”: "corgi@example.com",  
“facebook”: null,  
“facebook\_id”: null,  
“first\_name”: “Corgi”,  
“full\_name”: “Corgi The Dev”,  
“gender”: 0,  
“has\_password”: true,  
“image\_url”: “[https://c8.patreon.com/2/400/0000000](https://c8.patreon.com/2/400/0000000)”,  
“is\_deleted”: false,  
“is\_email\_verified”: false,  
“is\_nuked”: false,  
“is\_suspended”: false,  
“last\_name”: “The Dev”,  
“social\_connections”: {  
“deviantart”: null,  
“discord”: null,  
“facebook”: null,  
“spotify”: null,  
“twitch”: null,  
“twitter”: null,  
“youtube”: null  
},  
“thumb\_url”: “[https://c8.patreon.com/2/100/0000000](https://c8.patreon.com/2/100/0000000)”,  
“twitch”: null,  
“twitter”: null,  
“url”: “[https://www.patreon.com/corgithedev](https://www.patreon.com/corgithedev)”,  
“vanity”: “corgithedev”,  
“youtube”: null  
},  
“id”: “0000000”,  
“relationships”: {  
“pledges”: {  
“data”: []  
}  
},  
“type”: “user”  
},  
“links”: {  
“self”: “[https://www.patreon.com/api/user/0000000](https://www.patreon.com/api/user/0000000)”  
}  
}

How do I check if the Patron is a Patreon of my Creator Page?

I noticed that there is “data” inside “pledges” which is inside “relationships”.  
Do I check for my particular Patreon ID number inside data.relationships.pledges.data and if my Patreon ID is inside that array then that means that person has pledged to my Creation?

---

<div class="post-metadata">

**Author:** ![sam](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/sam/32/492_2.png) [@sam](https://www.patreondevelopers.com/u/sam)\
**Post date:** [June 26, 2018, 12:51pm UTC](https://www.patreondevelopers.com/t/json-data-to-determine-if-patron-member-is-a-creators-patreon-or-not/760/2 "2018-06-26T12:51:12Z")

</div>

Patreon use the JSON API standard, which separates out entity data from relationships — this means the entity data only needs to be included in the response once even if the entity appears as a relationship many times.

You can try parsing it yourself but your best bet is to find a JSON API client library that will do it for you. What language are you using? Searching “language JSON api client” will yield good results, e.g: “nodejs JSON api client”.

If you’re using php you can check out my Patreon PHP library which handles parsing response data for you: [https://github.com/1f991/patreon-php](https://github.com/1f991/patreon-php)

The response you receive will either contain no pledge or one pledge, as your api key is only able to access pledge data to your campaign[1]. You can determine if a user is an active patron of your campaign if there is a value in the pledge field _and_ that pledge is not declined, deleted or paused.

You can check the Entities in my library above to see the logic for determining pledge state (even if you’re not using PHP, the logic will be helpful for understanding how Patreon works.)

[1] unless Patreon have granted you multi-campaign access but that is not available unless you explicitly request it.

---

<div class="post-metadata">

**Author:** ![preston](https://avatars.discourse-cdn.com/v4/letter/p/a587f6/32.png) [@preston](https://www.patreondevelopers.com/u/preston)\
**Post date:** [June 27, 2018, 1:11pm UTC](https://www.patreondevelopers.com/t/json-data-to-determine-if-patron-member-is-a-creators-patreon-or-not/760/3 "2018-06-27T13:11:45Z")

</div>

Hi @sam

Thank you for the reply.  
I have checked your php library “patreon-php”.  
I have found this:

```
/**
     * An active pledge is not paused and is not currently declined.
     * Note: a pledge can be active even if the patron hasn't been charged yet
     * if the campaign does not charge upfront.
     *
     * @return bool
     */
    public function isActive(): bool
    {
        return $this->declined_since === null && $this->is_paused !== true;
    }

```

I have compared this to the JSON I received for the pledge result:  
var pledge = store.findAll(“pledge”)  
console.log(‘pledge.length’, pledge.length)  
console.log(‘pledge’, pledge)  
console.log(‘pledge[0].id’, pledge[0].id)  
console.log(‘pledge[0].creator’, pledge[0].creator)  
console.log(‘pledge[0].patron’, pledge[0].patron)

I can see the declined\_since (key/value) but I can’t find the is\_paused key/value pair.

In pledge[0].patron though I do see is\_deleted and is\_suspended.

Which variables should I check to make sure the Patron is an active supporter of my project?

Thank you.

---

<div class="post-metadata">

**Author:** ![sam](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/sam/32/492_2.png) [@sam](https://www.patreondevelopers.com/u/sam)\
**Post date:** [June 27, 2018, 1:30pm UTC](https://www.patreondevelopers.com/t/json-data-to-determine-if-patron-member-is-a-creators-patreon-or-not/760/4 "2018-06-27T13:30:30Z")

</div>

As noted in the documentation, some attributes are optional, on a [Pledge](https://docs.patreon.com/#pledge) for example:

```auto
// optional properties
"total_historical_amount_cents": <int>
"is_paused": <bool>
"has_shipping_address": <bool>

```

You must request these attributes explicitly to have them included in the response. However, a very important caveat is that when you explicitly request _any_ attribute you must explicitly request _every_ attribute you wish to be included. Therefore, if you would like to have access to `is_paused` _with_ the default data you’ll need to explicitly request `is_paused`, `created_at`, `amount_cents`, `declined_since`, `has_shipping_address` etc.

You can find an explanation of how to request optional data in the documentation here: [https://docs.patreon.com/#requesting-specific-data](https://docs.patreon.com/#requesting-specific-data)

My library builds a request URL containing each property of the entity, you can see how it does that here: [https://github.com/1f991/patreon-php/blob/master/src/Patreon/Resources/Resource.php#L128](https://github.com/1f991/patreon-php/blob/master/src/Patreon/Resources/Resource.php#L128)

Let me know if you need any other information 🙂

---

<div class="post-metadata">

**Author:** ![dhBxnny](https://avatars.discourse-cdn.com/v4/letter/d/cab0a1/32.png) [@dhBxnny](https://www.patreondevelopers.com/u/dhBxnny)\
**Post date:** [October 27, 2019, 10:11am UTC](https://www.patreondevelopers.com/t/json-data-to-determine-if-patron-member-is-a-creators-patreon-or-not/760/5 "2019-10-27T10:11:31Z")

</div>

Hey, I have a question about it.  
My bot is written on Node.js, and I have been trying to get the Patrons of a Creator for a while.

I don’t know what to do, nor I know which link I should send an API Request to.

I would love if someone displayed me an example of how would it be on Node.js as I have no idea as of right now. I have checked the API Documentation but I really don’t know what to use and what to do.

Thank you.

**Edit:** Would I need to get an access token or anything to access that? If so, how do I get it?

---

<div class="post-metadata">

**Author:** ![preston](https://avatars.discourse-cdn.com/v4/letter/p/a587f6/32.png) [@preston](https://www.patreondevelopers.com/u/preston)\
**Post date:** [November 2, 2019, 9:56pm UTC](https://www.patreondevelopers.com/t/json-data-to-determine-if-patron-member-is-a-creators-patreon-or-not/760/6 "2019-11-02T21:56:21Z")

</div>

Yeah you need a client id…

For my meteor js app…I did something like this…

```
var url = 'https://www.patreon.com/oauth2/authorize?response_type=code&client_id=' + clientid +'&redirect_uri=' + redirecturl

  
    // this function can fire onclick handler for any DOM-Element
    function fireClickEvent(element) {
        var evt = new window.MouseEvent('click', {
            view: window,
            bubbles: true,
            cancelable: true
        });

        element.dispatchEvent(evt);
    }

    // this function will setup a virtual anchor element
    // and fire click handler to open new URL in the same room
    // it works better than location.href=something or location.reload()
    function openNewURLInTheSameWindow(targetURL) {
        var a = document.createElement('a');
        a.href = targetURL;
        fireClickEvent(a);
    }

    function openNewTabOrNewWindow(targetURL) {
        var a = document.createElement('a');
        a.href = targetURL;

        a.target = '_blank'; // now it will open new tab/window and bypass any popup blocker!

        fireClickEvent(a);
    }

    openNewURLInTheSameWindow(url)
```
