We are excited to announce that the Ads API is now out of beta. The Ads API, part of the Marketing API Program, allows you to build tools that help marketers scale their Facebook presence. Over the past several months, we have significantly improved the stability, reliability, and performance of the Ads API. Today, several developers have been using the Marketing APIs to offer advanced functionality, provide comprehensive services to manage various Facebook products, and address custom needs for marketers.

If you are interested in applying for this open round of access to the Ads API, visit here. While we consider all requests, we will continue to prioritize the partners most likely to build socially-focused apps that provide high value to marketers.

In order to continue improving scalability, performance and reliability, we are migrating the Ads API from the legacy REST API to the Graph API. This is a transition that many of you have requested. Some Ads API methods are already available in the Graph API today. We plan on completing the transition by January 2012 and will only add new features to the Graph API. Begin planning now to migrate your apps to the Graph API. In addition, we have updated our guidelines to provide more transparency.

Getting Started with the Ads API

In order to use the Ads API (once accepted into the program), you must prompt the user for the ads_management permission.

After the user authorizes your app, you can make Graph API calls to access the user’s advertising account to manage Facebook Ads and Sponsored Stories.

<

p> The examples below demonstrate how to create a Page Like Sponsored Story:

curl -F "campaign_id=6003417011234" -F "bid_type=1" 
-F "max_bid=30" -F "targeting={'countries':['US']}" 
-F "creative={‘type’:9,’object_id’:125772667501234}" 
-F "name=test" 
"https://graph.facebook.com/act_368811234/adgroups?access_token=____"

via PHP:

<?php
  $creative_spec = array( 'type'=>9, 'object_id'=>125772667501234);
  $targeting_spec = array( 'countries' => array('US'));
  $bid_type = 1;
  $max_bid=30;
  $name = 'test';
  $account_id = 368811234;
  $campaign_id = 6003417011234;
  $access_token = 'access_token';

    // POST to Graph API endpoint to create an Ad
    $graph_url= "https://graph.facebook.com/"
      . "act_". $account_id . "/adgroups?"
      . "campaign_id=" . $campaign_id
      . "&bid_type=" . $bid_type
      . "&max_bid=" . $max_bid
      . "&creative=" . json_encode($creative_spec)
      . "&targeting=" . json_encode($targeting_spec)
      . "&name=" . urlencode($name)
      . "&method=POST"
      . "&access_token=" .$access_token;

    echo($graph_url);

    echo '<html><body>';
    echo file_get_contents($graph_url);
    echo '</body></html>';

?>

This examples below update a bid for an AdGroup

curl  -F "max_bid=100" 
"https://graph.facebook.com/6003493971234?access_token=___"

via PHP:

<?php
  $max_bid=30;
  $adgroup_id = 6003493971234;
  $access_token = 'access_token';

    // POST to Graph API endpoint to create an Ad
    $graph_url= "https://graph.facebook.com/"
      . $adgroup_id . "?"
      . "max_bid=" . $max_bid
      . "&method=POST"
      . "&access_token=" .$access_token;

    echo($graph_url);

    echo '<html><body>';
    echo file_get_contents($graph_url);
    echo '</body></html>';

?>

More details on AdGroup creation and updates here.

Releasing Power Editor

We are also releasing the source code of the Power Editor, our ad management tool, built using the Ads API. You can access it here. In addition to serving as a sample app, we think that some of you will build tools that are even better and more advanced. We will continue to add new features to the Power Editor as we continue to iterate on the Ads API.

Please let us know if you have any questions or feedback in the comments below.