Skip to content

Communityq content API version 2

Tim Benson edited this page Jan 2, 2018 · 3 revisions

Content API

The content API is a REST interface. It's old now, written 5+ years ago, is a little crude, and needs to be upgraded to our latest standards (JWT auth + SSL)... but it gets the job done.

Rules

  • All requests should be POSTs
  • URL is api.communityq.com
  • All requests must at least include the following parameters
    • account => name of client folder
    • key => IAJ8a3ho8S$Ehno7S$HN*tDgtd (hard-coded)
    • action => name of action
  • Output is JSON array:
    • status => ERROR or OK
    • message => Returned if status = error
    • result => JSON array of action result if status = OK

Actions & their expected parameters

  • Content.get => retrieve an item

    • You can either fetch specific items:
      • id=12345 => get a single
      • ids=12,34,56 => get multiple items
    • Or search for items (I can clarify any of these params):
      • content_source
      • content_class
      • sub_type
      • user_id
      • list_type
      • most_viewed_timespan
      • most_commented_timespan
      • print_issue
      • town_list
      • category_list
      • search_filter
      • search_filter_mode
      • fielded_data[field]
      • story_access
      • date_start
      • date_end
      • where_extras
      • additional_columns
      • event_date_start
      • event_date_end
      • event_mode
      • event_span
      • order_by
      • order_sort
      • limit
      • get_all
      • page_size
      • page_current
  • Content.create => Make a new, blank item

    • type defaults to stories
  • Content.put => Write an update to an item

    • id or guid (aka foreign key) is required

    • asset => JSON key/value object of fields for the main content asset. Database schema is included in this wiki.

    • media => JSON array of category assignments. Use one of the following:

      ```
      {
        clear: true, // Erases all 
        add: [
                  {asset: 12345, caption: 'my caption', credit: 'joe smith'},
                  {asset: 12345, caption: 'my caption', credit: 'joe smith'}
              ], // Adds to existing.
        remove: (same aray format as add), // Remove from existing
        reset: (same aray format as add), // Reset to just this list
      }
      ```
      
    • categories => JSON array of category assignments. Use one of the following:

      ```
      {
        clear: true, // Erases all category associations
        add: [1,2,'sports'], // Adds to existing. Use ID or slug
        remove: [1,2,'sports'], // Remove from existing
        reset: [1,2,'sports'], // Reset to just this list
      }
      ```
      
    • subsites => JSON array of subssite assignments. Use one of the following:

      ```
      {
        clear: true, // Erases all associations
        add: [1,2,'The daily banner'], // Adds to existing. Use ID or name
        remove: [1,2], // Remove from existing
        reset: [1,2], // Reset to just this list
      }
      ```
      
  • Users.get

    • You can either fetch specific items:
      • id=12345 => get a single
      • ids=12,34,56 => get multiple items
    • Or search for items (I can clarify any of these params):
      • list_type
      • photo_only
      • search_filter
      • search_filter_mode
      • exclude_staff
      • staff_only
      • where_extras
      • town_list
      • get_all
      • limit
      • page_size
      • page_current
      • order_by
      • order_sort
      • submission_count
      • online_now
      • tag_filter
  • Users.create => Make a new, blank record. No parameters.

  • Users.put

    • id, email, or username is required
    • asset => JSON key/value object of fields for the main content asset. Database schema is included in this wiki.
  • Categories.get => Get a category or tree of categories

    • Pass in an id or identifier (slug) to get a specific category
    • Pass in nothing to get the whole tree
  • Categories.create => Make a new, blank record.

    • parent => ID of parent category
  • Categories.put

    • Either id or identifier is required
    • asset => JSON key/value object of fields for the main content asset. Database schema is included in this wiki.
  • Categories.getOrCreate

    • Pass in title of category
    • It will return a full category asset from the DB
  • Media.get

    • id or file is required
  • Media.create

    • type can be photo (defaults to this if blank), video, or file
  • Media.put

    • id required
    • file => binary multipart file data for updating the physical file
    • asset => JSON key/value object of fields for the main content asset. Database schema is included in this wiki.
  • Media.post

    • This endpoint will take the first file found in the post data, import it, and return the asset information.
    • The one requirement is that a file needs to be present.
    • asset => Pass this in as JSON key/value object to update the content asset with once imported.
  • Config.get => No params, returns site config variables

  • Dsn.get => No params, returns database connection information

Clone this wiki locally