Skip to content
Twitter Ads API SDK for Crystal
Crystal Makefile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
proto
samples
spec
src
.editorconfig
.gitignore
.travis.yml
LICENSE
Makefile
README.md
shard.yml

README.md

twitter-ads.cr Build Status

Twitter Ads API SDK for Crystal.

  • crystal: 0.30.0

Usage

require "twitter-ads"

# client = TwitterAds::Client.from_twurlrc("~/.twurlrc")
client = TwitterAds::Client.new(
  CONSUMER_KEY,
  CONSUMER_SECRET,
  ACCESS_TOKEN,
  ACCESS_TOKEN_SECRET
)

accounts = client.accounts(count: 200)
accounts.req.to_s             # => "https://ads-api.twitter.com/5/accounts.json?count=200"
accounts.rate_limit           # => "2000"
accounts.rate_limit_remaining # => "1997"
accounts.rate_limit_reset     # => 1564851820
accounts.size                 # => 16
accounts.next_cursor?         # => nil

accounts.each do |a|
  a.id                        # => "18ce54d4x5t"
  a.name                      # => "API McTestface"

  campaigns = client.campaigns(a.id)
  campaigns.each do |c|
    c.name                    # => "batch campaigns"

API

TwitterAds::Client

  • accounts() : Api::Accounts
  • account_media(account_id : String) : Api::AccountMedia
  • authenticated_user_access(account_id : String) : AuthenticatedUserAccess
  • campaigns(account_id : String) : Api::Campaigns
  • cards_all(account_id : String, card_uris : Array(String)) : Api::CardsAll
  • cards_image_app_download(account_id : String) : Api::CardsImageAppDownload
  • cards_image_conversation(account_id : String) : Api::CardsImageConversation
  • cards_image_direct_message(account_id : String) : Api::CardsImageDirectMessage
  • cards_poll(account_id : String) : Api::CardsPoll
  • cards_video_app_download(account_id : String) : Api::CardsVideoAppDownload
  • cards_video_conversation(account_id : String) : Api::CardsVideoConversation
  • cards_video_direct_message(account_id : String) : Api::CardsVideoDirectMessage
  • cards_video_website(account_id : String) : Api::CardsVideoWebsite
  • cards_website(account_id : String) : Api::CardsWebsite
  • draft_tweets(account_id : String) : Api::DraftTweets
  • funding_instruments(account_id : String) : Api::FundingInstruments
  • line_item_apps(account_id : String) : Api::LineItemApps
  • line_items(account_id : String) : Api::LineItems
  • line_item_placements() : Api::LineItemPlacements
  • media_creatives(account_id : String) : Api::MediaCreatives
  • media_library(account_id : String) : Api::MediaLibrary
  • preroll_call_to_actions(account_id : String) : Api::PrerollCallToActions
  • promoted_accounts(account_id : String) : Api::PromotedAccounts
  • promoted_tweets(account_id : String) : Api::PromotedTweets
  • scheduled_promoted_tweets(account_id : String) : Api::ScheduledPromotedTweets
  • scheduled_tweets(account_id : String) : Api::ScheduledTweets
  • scoped_timeline(account_id : String) : Api::ScopedTimeline
  • targeting_criteria(account_id : String, line_item_ids : Array(String)) : Api::TargetingCriteria
  • targeting_criteria_locations(country_code = nil, location_type = nil, q = nil) : Api::TargetingCriteriaLocations
  • tweet_previews(account_id : String, tweet_type : String, tweet_ids : Array(Int64)) : Api::TweetPreviews

with_deleted, with_draft, count, cursor argments are also available in all methods if possible.

See src/twitter-ads/api/ for more details.

Models

./src/twitter-ads/models

Samples

Actual usages are in ./samples/

Protobuf

schema (version 2)

generated crystal codes

Protobuf-related files are not read by default. To use it, you need to install protobuf.cr and require above codes.

require "protobuf"
require "twitter-ads/proto"

Installation

Add this to your application's shard.yml:

dependencies:
  twitter-ads:
    github: maiha/twitter-ads.cr
    version: 0.5.1

Development

$ crystal spec

NOTE

  • media_library: media_id returns String (document says Type: long)
  • line-items: tracking_tags returns object (document says Type: String)
  "tracking_tags": [
    {
      "tracking_partner": "DOUBLE_CLICK",
      "tracking_tag": "https://ad.doubleclick.net/..."
    }
  ]
  • targeting-criteria: targeting_value sometimes returns 0 (Integer).

Roadmap

  • Analytics
    • Asynchronous Analytics
    • Reach and Average Frequency
    • Synchronous Analytics
    • Auction Insights
    • Active Entities
  • Audiences
    • Insights
    • Keyword Insights
    • Tailored Audience Permissions
    • Tailored Audiences
    • Audience Intelligence
    • Tailored Audiences Users
  • Campaign Management
    • Accounts
    • Authenticated User Access
    • Bidding Rules
    • Campaigns
    • Content Categories
    • Features
    • Funding Instruments
    • IAB Categories
    • Line Items
    • Line Item Apps
    • Line Item Placements
    • Media Creatives
    • Promoted Accounts
    • Promoted Tweets
    • Promotable Users
    • Reach Estimate
    • Scheduled Promoted Tweets
    • Targeting Criteria
    • Targeting Options
    • Targeting Suggestions
    • Tax Settings
    • User Settings
  • Creatives
    • Account Media
    • Image App Download Cards
    • Image Conversation Cards
    • Scheduled Tweets
    • Video App Download Cards
    • Video Conversation Cards
    • Video Website Cards
    • Website Cards
    • Preroll Call To Actions
    • Tweets
    • Image Direct Message Cards
    • Video Direct Message Cards
    • Media Library
    • Cards Fetch
    • Poll Cards
    • Draft Tweets
    • Tweet Previews
  • Measurement
    • App Event Provider Configurations
    • App Event Tags
    • Web Event Tags
    • App Lists
    • Conversion Attribution
    • Conversion Event

Contributing

  1. Fork it (https://github.com/maiha/twitter-ads.cr/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

You can’t perform that action at this time.