Delegates

 

ON THIS PAGE      Show

 

 

 

 

Description

For presidential primaries, returns the delegate allocation data of a specific type for Democrats, Republicans or both. The types represent the National Presidential Delegate Tracking Reports, and the returned data elements are the same as in those reports. However, the reports reflect the delegate allocation as of a specific date (for example, two days after Super Tuesday) while the Delegates method returns the delegate allocation at the time of request.

Required Request Headers

 

Header

Description

Example

x-api-key

Specifies the API key to authorize the request. The x-apikey header is also currently supported.

apikey

Accept-Encoding

Compresses the response to the gzip format.

gzip

Optional Request Header

 

Header

Description

Example

Accept

The MIME type of the returned data format: XML or JSON. The default is application/xml. The format parameter value takes precedence over the Accept header value when both are specified.

application/json

Request URI

 

Method

Request URI

GET

https://api.ap.org/v3/elections/delegates/{electionYear}?[{OptionalParameters}]

 

  Important

 

The request URI must be URL-encoded.

 

 

 

Required Parameter

Parameter

Description

Example

electionYear

Year of the presidential election (in the YYYY format) for which to return delegate data.

2024

Optional Parameters

The following parameters can be used to control the returned data and format:

 

Parameter

Description

Example

party

The code of the party for which to return delegate data. Multiple values must be separated by a comma. Possible values are "Dem,GOP" (this is the default), "Dem" and "GOP".

Dem

type

The type of delegate data to return. Multiple values are not allowed. Possible values are:

  • summary. Returns the cumulative ("DelSum") data, which is the current summary delegate total for each candidate across the country as well as the change in the past 24 hours, past week and past month. This is the default value.

  • state. Returns the state-by-state ("DelState") data, which is the current delegate total for each candidate in each state and at the national level as well as the change in the past 24 hours.

  • super. Returns the unpledged/super delegates ("DelSuper") data, which is the current delegate and unpledged delegate totals for each candidate in each state and at the national level (note that anonymous unpledged delegates are not counted at the state level).

state

format

The response format (xml or json). The format parameter value takes precedence over the Accept header value when both are specified. If no format is specified as the format parameter value or in the Accept header, XML is returned.

json

resultsType

Indicates whether to return live or test delegate data. Possible values are t or test for test data and l or live for live data (this is the default).

  Important

 

To receive test data, make sure to add the optional resultsType=t parameter to the request URL.

 
   

t

test

Request URI Examples

Sample URI

Returned Results

https://api.ap.org/v3/elections/delegates/2024?format=json

2024 cumulative ("DelSum") delegate allocation data for both parties in the JSON format.

https://api.ap.org/v3/elections/delegates/2024?party=Dem&type=state

2024 state-by-state ("DelState") delegate allocation data for Democrats  in the XML format.

Response

On success, returns the standard HTTP status code of "200 – OK" and results in the requested format (XML or JSON). The response contains the delegate allocation data of the requested type. For information about error codes, see API Codes.

Data Elements

XML Element

JSON Property

Description

delReportType

"delReportType"

The tag for this report: delSum, delState or delSuper.

@ApiVersion

"apiVersion"

The API version number; for example, 3.1.

@ApiBuild

"apiBuild"

The API build number; for example, 3.1.461.

...

...

For information about the data elements in each delegate report type, see:

link

"nextrequest"

Indicates a link for the next request that must be used to request data newer than the data in the previously returned response.

@rel="next"

@href

 

The specific URL for the next request.

Response Examples

The following examples show partial JSON and XML responses containing the state-by-state ("DelState") delegate allocation data.

 

JSON

XML

...

...