[ Web Proxy ]
URL:
Viewing: https://developers.buffer.com/examples/../examples/../examples/../examples/get-organizations.html [Back]  [Original]

Get Organizations - Buffer API
Buffer API [Buffer API]
Search docs... K
API Status Get API Key
ExamplesGet Organizations

Get Organizations

Try in Explorer
Copy Page

Fetch all of the organizations that belong to the authenticated account.

GraphQLcURLNode.jsPythonPHP
Copy Copied!
query GetOrganizations {
  account {
    organizations {
      id
      name
      ownerEmail
    }
  }
}
Copy Copied!
curl -X POST 'https://api.buffer.com' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -d '{"query": "query GetOrganizations {\n  account {\n    organizations {\n      id\n      name\n      ownerEmail\n    }\n  }\n}"}'
Copy Copied!
async function getOrganizations() {
  const response = await fetch('https://api.buffer.com', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer YOUR_API_KEY',
    },
    body: JSON.stringify({
      query: `
      query GetOrganizations {
        account {
          organizations {
            id
            name
            ownerEmail
          }
        }
      }
      `,
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

getOrganizations();
Copy Copied!
import requests

query = """
query GetOrganizations {
  account {
    organizations {
      id
      name
      ownerEmail
    }
  }
}
"""

response = requests.post(
    "https://api.buffer.com",
    headers={
        "Content-Type": "application/json",
        "Authorization": "Bearer YOUR_API_KEY",
    },
    json={
        "query": query,
    },
)

data = response.json()
print(data)
Copy Copied!
<?php

$query = '
query GetOrganizations {
  account {
    organizations {
      id
      name
      ownerEmail
    }
  }
}
';

$payload = [
    'query' => $query,
];

$ch = curl_init('https://api.buffer.com');
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => [
        'Content-Type: application/json',
        'Authorization: Bearer YOUR_API_KEY',
    ],
    CURLOPT_POSTFIELDS => json_encode($payload),
    CURLOPT_RETURNTRANSFER => true,
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
print_r($data);

Web Proxy Viewer  |  New URL  |  Original Page