The ba­sic struc­ture of the Ar­cGIS Plat­form is an or­ga­ni­za­tion with a num­ber of users. Each user can own a num­ber of items. Items come in four ba­sic types - lay­ers, maps ap­pli­ca­tions, and files. Items can be col­lected to­gether into groups, re­gard­less of what user or or­ga­ni­za­tion they are as­so­ci­ated with. Groups can in­clude a num­ber of users, who than have ac­cess to that groups items.

All meth­ods in the li­brary be­sides the ini­tial Arcgis() func­tion re­turn a Promise by de­fault. How­ever, one can also use call­backs by pass­ing a func­tion as the last pa­ra­me­ter on each method. For ex­am­ple, get­ting an item by ID can be done in two ways:

arcgis.item('id').then(cb)
// or
arcgis.item('id', cb)

Ar­cGIS

There are a num­ber of ways to au­then­ti­cate with the plat­form - which in­clude sup­port for fed­er­ated ac­counts and things like that. If you need any­thing other than a to­ken, open an is­sue. We’ll get there!

Ini­tial­ize the client li­brary ses­sion to ac­cess the API ei­ther as an anony­mous user, or as an au­then­ti­cated mem­ber of an or­ga­ni­za­tion. Call­ing ArcGIS() with no pa­ra­me­ters will set up an in­stance of the plat­form that talks to Ar­cGIS On­line as a pub­lic, anony­mous user.

Params: JSON Ob­ject with the fol­low­ing op­tions;

Op­tions Type De­fault
to­ken String none
do­main URL www.ar­cgis.com/

Re­turns: JSON Ob­ject with Ar­cGIS meth­ods.

{
  request: Function,      // Makes requests to the domain
  search: Function,       // Queries the API
  user: Function,         // Interact with a user
  organization: Function, // Interact with an org
  group: Function,        // Interact with a group
  item: Function,         // Interact with an item
  layer: Function,         // Interact with an layer
  map: Function,          // Interact with an map
  application: Function,  // Interact with an application
  file: Function,         // Interact with an file
}
Ex­am­ple

You can prob­a­bly set up mul­ti­ple of these suck­ers in one ses­sion to have ac­cess to pub­lic and pri­vate stuff at the same time.

var ArcGIS = require('arcgis')
// Create an anonymous session with www.arcgis.com
var anonAGO = ArcGIS()
// Create an authenticated session with www.arcgis.com
var authAGO = ArcGIS({
  token: token
})
// Creat an anonymous session with ArcGIS Server
var serverGIS = ArcGIS({
  domain: 'myGIS.myurl.com'
})

re­quest

Re­quest has a lot of func­tion­al­ity that I’ve been told we need, but I’m re­ally not sure what any of it is. Right now, this bare-bones re­quest works fine. We’ll add more to it as needed.

Re­quest uses in­for­ma­tion in the client to make calls to the API. It takes a url sub­string, a JSON ob­ject, and a boolean.

Re­quest ap­pends the URL to the clients do­main and the om­nipresent shar­ing/​rest’. The JSON ob­ject gets processed into pa­ra­me­ters. The boolean de­fines the re­quest is GET (de­fault, false) or POST (true). Re­quest also ap­pends the to­ken that the cur­rent client ses­sion is au­then­ti­cated with, and de­fines the re­sponse for­mat as JSON.

Some ser­vices - like us­age, analy­sis, things like that — re­quire a dif­fer­ent root URL, since they are an in­de­pen­dent API.

Pa­ra­me­ters: Op­tions Ob­ject

Op­tions Type De­fault
url String /
form Ob­ject {}
post Boolean false
rootURL String ${domain}/sharing/rest

Re­sponse: Promise that re­solves to what­ever the end­point re­turns.

Ex­am­ple
arcgis.request()
.then( function (results) {
  // This calls the endpoint self, and returns a version number of the API.
  console.log(results)
})

this is grow­ing in sup­port as needed

Searches for items, users, and groups within the plat­form.

Params: Op­tions ob­ject

Op­tion De­fault De­scrip­tion
queryS­tring “”’’ String, what to search for. Can be com­pli­cated.
num 100 Re­sults per page
page 0 Page of re­sults to re­turn
sort cre­at­ed’ Field to sort re­sults on
or­der de­sc’ asc’ or de­sc’, as­cend­ing or de­scend­ing

Re­sults: Promise that re­solves to a pag­i­nated search re­sults Ob­ject

{
  nextStart: Number,  // if -1, there are no more results
  num: Number,        // Number of items per page returned
  query: String,      // The query string that got us here
  results: Array,     // An array of all the items that match the query
  start: Number,      // The index of the item that starts this batch of results
  total: Number,      // Total number of items that match the query
  pages: Number,      // How many pages of results there are
  currentPage: Number // Index of the current page
}
Ex­am­ple
var options = {
  queryString: 'owner:NikolasWise AND (type:"Feature Service")',
  num: 100
}
arcgis.search(options)
.then(function(results) {
  console.log(results)
})


user

Every method off ArcGIS() re­turns a promise, and in­volves mak­ing web re­quests to the do­main.

This ob­ject is used to in­ter­act with a user - your own user ac­count, other users in your or­ga­ni­za­tion, or pub­licly avail­able users that are not as­so­ci­ated with your or­ga­ni­za­tion. This method is also used to cre­ate new users by invit­ing them to your or­ga­ni­za­tion.

Params: A user­name string

Params Type De­fault
User­name String none

Re­turns: JSON user ob­ject with man­age­ment meth­ods.

{
  created: Date,            // when this user was created
  firstName: String,        // recorded first name of the user
  fullName: String,         // recorded name of the user
  lastName: String,         // recorded last name of the user
  provider: String,         // ???
  username: String,         // hard username for the user. Never changes.
// the following are not returned if the user is private
  email: String,            // email address of user
  culture: String,          // two letter lang code ex: 'en'
  description: String,      // text description set by the user
  privileges: Array,     // Strings that denote actions
  favGroupId: String,       // ID of user favorites group
  groups: Array,            // Group objects associated with the user
  orgId: String,            // ID of the org the user belongs too
  modified: Date,           // date when the user
  region: String,           // two letter country code ex: 'us'
  tags: Array,              // array of tags that user has used, with counts
  thumbnail: String,        // name of the users thumbnail image ex: 'coolguy.jpg'
  units: String,            // 'imperial' or 'metric'
  update: Function,         // updates the user information
  delete: Function,         // deletes a user
  content: Function,        // gets users content
  tags: Function,           // returns the users tags?
  enable: Function,         // enables a disabled user
  disable: Function,        // disables a user
}
Ex­am­ple
arcgis.user(username)
.then(function (user){
  console.log(user)
})

user.up­date

Takes an op­tions ob­ject, and sets the users in­for­ma­tion to the op­tions pro­vided. Re­turns an er­ror, or the up­dated user ob­ject.

Params: Op­tions JSON Ob­ject

Op­tions Type De­scrip­tion
pre­ferred­View String Web’ / GIS / null’
de­scrip­tion String Plain text de­scrip­tion of the user.
thumb­nail Path The file to be used as the users pro­file im­age.
pass­word String Set the users pass­word to the new string.
full­name String The full name of the user.
email String Email ad­dress to con­tact the user at.
cul­ture String Cul­ture code for the user.
re­gion String Re­gion code for the user.

Re­turns: Promise that re­solves to the up­dated user ob­ject.

Ex­am­ple
arcgis.user(username)
.then(function (user) {
  var options = {description: 'just this person, you know?'}
  return user.update(options)
})
.then(function (user) {
  console.log(user)
})

user.con­tent

This is not us­ing the user con­tent method from the Ar­cGIS API. In­stead, this is us­ing a the search method and pre-fill­ing the pa­ra­me­ters to lo­cate the cur­rent user’s con­tent. This is done to have all con­tent calls share re­sponse prop­er­ties. The raw user con­tent api call is the only call in the plat­form that does not re­turn a pag­i­nated re­sults ob­ject.

Re­turns an ar­ray of all of the users items and fold­ers. If passed a folder id, will re­turn an ar­ray of the items in that folder. These items have the same sta­tic prop­er­ties as the re­sults of item, but do not have meth­ods at­tached to them.

Params: Op­tions Ob­ject

Op­tions De­fault De­scrip­tion
num 100 Re­sults per page
page 0 Page of re­sults to re­turn
sort cre­at­ed’ Field to sort re­sults on
or­der de­sc’ asc’ or de­sc’, as­cend­ing or de­scend­ing

Re­turns: Promise that re­solves to a search re­sults ob­ject.

{
  nextStart: Number,  // if -1, there are no more results
  num: Number,        // Number of items per page returned
  query: String,      // The query string that got us here
  results: Array,     // An array of all the items that match the query
  start: Number,      // The index of the item that starts this batch of results
  total: Number,      // Total number of items that match the query
  pages: Number,      // How many pages of results there are
  currentPage: Number // Index of the current page
}
Ex­am­ple
arcgis.user(username)
.then(function (user) {
  return user.content()
})
.then(function (results) {
  console.log(results)
})

user.tags

All con­tent has a set of tags as­so­ci­ated with it. This call re­turns all the tags a user has ap­plied to their con­tent, with counts for the num­ber of time each tag ap­pears.

Re­turns Promise that re­solves to a JSON Ob­ject.

{
  tags: [
    {
      count: Number,
      tag: String
    }
  ]
}
Ex­am­ple
arcgis.user(username)
.then(function (user){
  return user.tags()
})
.then(function (tags) {
  console.log(tags)
})

user.fa­vorites

Users store their their fa­vorite items in a group as­so­ci­ated with their ac­count. Get­ting a users fa­vorites is sim­i­lar to get­ting any other groups con­tent.

Params: Op­tions Ob­ject

Params De­fault De­scrip­tion
num 100 Re­sults per page
page 0 Page of re­sults to re­turn
sort cre­at­ed’ Field to sort re­sults on
or­der de­sc’ asc’ or de­sc’, as­cend­ing or de­scend­ing

Re­turns: Promise that re­solves to a search re­sults ob­ject.

{
  num: Number,       // Total number of items that could be returned
  total: Number,     // Total number of items in favorites
  query: String,     // Search string used to get these
  start: Number,     // Which item this page starts with
  nextStart: Number, // Which item next page starts with.
  results: Array     // Item objects
}
Ex­am­ple
arcgis.user(username)
.then(function (user) {
  return user.favorites()
})
.then(function (results) {
  console.log(results)
})

user.en­abled

En­ables and dis­ables the user within the or­ga­ni­za­tion. Pass­ing no boolean to the method will re­turn the cur­rent state of the user.

If a user is dis­abled, that means that their ac­count is not ac­tive, but has not been deleted. A dis­abled user still counts to­wards your or­ga­ni­za­tions max­i­mum num­ber of users.

Params: En­abled

Params Type De­fault
User En­abled Boolean none

Re­turns: Promise that re­solves to the up­dated user ob­ject.

Ex­am­ple
arcgis.user(username)
.then(function (user) {
  return user.enabled(false)
})
.then(function (user) {
  console.log(user)
})

user.delete

Deletes the user. This can­not be un­done.

Re­turns: Promise that re­solves to an con­fir­ma­tion ob­ject.

Ex­am­ple
arcgis.user(username)
.then(function (user) {
  return user.delete()
})
.then(function (confirmation) {
  console.log(confirmation)
})

user.cre­ate

Cre­ates a new user in your or­ga­ni­za­tion.

Ex­am­ple:
var options = {
}
arcgis.user.create(options)
.then(function (???) {
  console.log(???)
})

or­ga­ni­za­tion

Or­ga­ni­za­tions are the cen­tral en­ti­ties in the Ar­cGIS plat­form. All users be­long to an Or­ga­ni­za­tion, even de­vel­oper ac­counts, which be­long to an or­ga­ni­za­tion with a sin­gle user.

This method is used to re­trieve and in­ter­act with an Or­ga­ni­za­tion within the do­mains Por­tal - Ar­cGIS On­line for ex­am­ple has many or­ga­ni­za­tions that can be in­ter­acted with. An on-premises ver­sion of Por­tal or Server may have fewer, if not just one.

Params: String of an Org Id.

Params Type De­fault
Org Id String self

Re­turns: Promise that re­solves to the Org Ob­ject

{
  access: String,                  //
  availableCredits: Number,        //
  backgroundImage: String,         //
  created: Date,                   //
  culture: String,                 //
  defaultBasemap: Object,          //
  defaultExtent: Object,           //
  description: String,             //
  featuredGroups: Array,           //
  featuredGroupsId: String,        //
  helpBase: String,                //
  id: String,                      //
  ipCntryCode: String,             //
  modified: Date,                  //
  name: String,                    //
  region: String,                  //
  staticImagesUrl: String,         //
  subscriptionInfo: Object,        //
  supportsHostedServices: Boolean, //
  supportsOAuth: Boolean,          //
  thumbnail: String,               //
  units: String,                   //
  urlKey: String,                  //
  user: Object,                    //
  update: Function,                // Updates the orgs info
  members: Function,               // Gets all users in the org
  content: Function,               // Gets all content in the org
  featured: Function               // Gets the orgs featured items
}
Ex­am­ple
arcgis.organization()
.then(function (organization) {
  console.log(organization)
})

or­ga­ni­za­tion.up­date

All op­tions that are set­table with this method have yet to be fully plumbed.

Takes an op­tions ob­ject, and sets the or­ga­ni­za­tion’s in­for­ma­tion to the op­tions pro­vided. Re­turns an er­ror, or the up­dated or­ga­ni­za­tion ob­ject.

Params: Op­tions JSON Ob­ject

Op­tions Type De­scrip­tion
name String, The char­ac­ter limit is 250.
ac­cess String, Set­ting to pub­lic al­lows anony­mous users to
de­scrip­tion String, De­scribes the or­ga­ni­za­tion.
sum­mary String Short de­scrip­tion of the or­ga­ni­za­tion, less than 256 char­ac­ters.
can­Share­Pub­lic Boolean, Al­lows mem­bers of the or­ga­ni­za­tion to share out­side the or­ga­ni­za­tion
canSearch­Pub­lic Boolean, Al­lows mem­bers of the or­ga­ni­za­tion to search out­side the or­ga­ni­za­tion.
thumb­nail String, Ac­cept­able im­age for­mats are PNG, GIF, and JPEG
urlKey String, The pre­fix that will be used in the URL for this por­tal, for ex­am­ple, .maps.ar­cgis.com.
url­Host­name String, A cus­tom URL for this por­tal.
cul­ture String The de­fault lo­cale (lan­guage and coun­try)in­for­ma­tion.

Re­turns: Promise that re­solves to the organization ob­ject

Ex­am­ple
arcgis.organization()
.then(function (organization) {
  var options = {description: 'We are super professional'}
  return organization.update(options)
})
.then(function (organization) {
  console.log(organization)
})

or­ga­ni­za­tion.mem­bers

Gets the mem­bers within an or­ga­ni­za­tion. Takes a num­ber, and re­turns as a pag­i­nated list with that num­ber of mem­bers per page. Re­turns 100 mem­bers per page by de­fault.

Params: Op­tions Ob­ject

Op­tions De­fault De­scrip­tion
num 100 Re­sults per page
page 0 Page of re­sults to re­turn
sort cre­at­ed’ Field to sort re­sults on
or­der de­sc’ asc’ or de­sc’, as­cend­ing or de­scend­ing

If the nextStart value is -1, that means your on the last page of the re­sults. The ob­jects re­turned in the users ar­ray are the same as in user.get()

Re­turns: Promise that re­solves to the organization ob­ject

{
  nextStart: Number,
  num: Number,
  start: Number,
  total: Number,
  users: Array
}
Ex­am­ple
arcgis.organization()
.then(function(organization) {
  return organization.members()
})
.then(function (members) {
  console.log(members)
})

or­ga­ni­za­tion.con­tent

Gets the items in an or­ga­ni­za­tion. Takes a num­ber, and re­turns as a pag­i­nated list with that num­ber of items per page. Re­turns 100 items per page by de­fault, start­ing at the first page of re­sults.

This is a short­cut helper for the search method with the query needed to tar­get an org pre­de­fined.

Params: Op­tions Ob­ject

Op­tions De­fault De­scrip­tion
num 100 Re­sults per page
page 0 Page of re­sults to re­turn
sort cre­at­ed’ Field to sort re­sults on
or­der de­sc’ asc’ or de­sc’, as­cend­ing or de­scend­ing

Re­turns: Promise that re­solves to the search re­sults ob­ject

{
  nextStart: Number,
  num: Number,
  query: String
  results: Array,
  start: Number,
  total: Number
  pages: Number,
  currentPage, Number
}
Ex­am­ple
arcgis.organization()
.then(function (organization) {
  return organization.content()
})
.then(function(content) {
  console.log(content)
})

or­ga­ni­za­tion.fea­tured

Or­ga­ni­za­tions can add items to a group that is for spe­cially fea­tured con­tent’, items that may be com­mon or high-traf­fic within the or­ga­ni­za­tion. This group is dis­played on the orgs home page.

Takes a num­ber, and re­turns a pag­i­nated list of items within the or­ga­ni­za­tions fea­tured group.

This method is the same as group.content(), but with the group id pre­filled from the or­ga­ni­za­tions pro­file.

Params: Op­tions Ob­ject

Op­tions De­fault De­scrip­tion
num 100 Re­sults per page
page 0 Page of re­sults to re­turn
sort cre­at­ed’ Field to sort re­sults on
or­der de­sc’ asc’ or de­sc’, as­cend­ing or de­scend­ing

Re­turns: Promise that re­solves to the search re­sults ob­ject

Ex­am­ple
arcgis.organization()
.then(function (organization) {
  return organization.featured()
})
.then(function(featured) {
  console.log(featured)
})

group

In the Ar­cGIS plat­form, groups are used to ag­gre­gate users and con­tent to­gether. They can con­tain items and users from out­side or­ga­ni­za­tions, be au­tho­rized to ac­cess ap­plic­tions and con­tent pur­chased from the mar­ket­place, and are used to man­age things like user fa­vorites and fea­tured con­tent.

This ob­ject us used to in­ter­act with a group. Any group that your user has per­mis­sions to ac­cess can be in­ter­acted with via this method. As with the user ob­ject, call­ing this method with no pa­ra­me­ters al­lows you to cre­ate a new group.

Params: A group id string

Params Type De­fault
GroupID String none

Re­turns: Promise that re­solves to group ob­ject with man­age­ment meth­ods.

{
  access: String,           //
  capabilities: Array,      //
  created: Date,            //
  description: String,      //
  id: String,               //
  isFav: Boolean,           //
  isInvitationOnly: true    //
  isReadOnly: Boolean,      //
  isViewOnly: Boolean,      //
  modified: Date,           //
  owner: String,            //
  phone: String,            //
  provider: String,         //
  providerGroupName: String,//
  snippet: String,          //
  sortField: String,        //
  sortOrder: String,        //
  tags: Array,              //
  thumbnail: String,        //
  title: String,            //
  userMembership: {         //
    applications: Number    //
    memberType: String,     //
    username: String,       //
  }                         //
  update: function (),      // Updates the group information
  content: function (),     // Gets the content in the group
  members: function (),     // Gets the members in the group
  removeUsers: function (), // Remove a member from the group
  addUsers: function (),    // Add a member to the group
  join: function (),        // Submit a request to join the group
  leave: function (),       // Leave the group
  changeOwner: function (), // Reassign the owner of the group
  delete: function ()       // Delete the group
}
Ex­am­ple
arcgis.group(id)
.then(function(group) {
  console.log(group)
})

group.up­date

Up­dates the in­for­ma­tion for a group.

Up­dat­a­ble params are still TBD

Pa­ra­me­ters: JSON Op­tions Ob­ject

Re­turns: Promise that re­solves to up­dated group ob­ject

Ex­am­ple
arcgis.group(id)
.then(function (group) {
  return group.update({ title: "My New Group Name" })
})
.then(function (group) {
  console.log(group)
})

group.con­tent

This item re­sults ob­ject is sim­i­lar to a search re­sults ob­ject.

Gets the items that are ag­gre­gated with in the group.

Op­tions De­fault De­scrip­tion
num 100 Re­sults per page
page 0 Page of re­sults to re­turn
sort cre­at­ed’ Field to sort re­sults on
or­der de­sc’ asc’ or de­sc’, as­cend­ing or de­scend­ing

Re­turns: Promise that re­solves to JSON earch re­sults Ob­ject

{
  nextStart: Number,
  num: Number,
  query: String
  results: Array,
  start: Number,
  total: Number
  pages: Number,
  currentPage, Number
}
Ex­am­ple
arcgis.group(id)
.then(function (group) {
  return group.content()
})
.then(function (content) {
  console.log(content)
})

group.mem­bers

This item is not pag­i­nated, not sim­i­lar to a search re­sults ob­ject. Comme se, comme ca I guess.

Gets the users within a group, along with the groups owner and an ar­ray of group ad­mins. It does not take params. Un­known why this is dif­fer­ent, just one of those things.

Re­turns: Promise that re­solves to a JSON Ob­ject

{
  admins: Array
  owner: String
  users: Array
  length: Number
}
Ex­am­ple
arcgis.group(id)
.then( function (group) {
  return group.members()
})
.then(function (members) {
  console.log(members)
})

group.re­moveUsers

addUsers, inviteUsers, and removeUsers can all ac­cept an ar­ray of user­names, or a sin­gle user­name as a string.

Re­moves one or more users from the group.

Params: Ar­ray of user­name strings.

Re­turns: Promise that re­solves to a JSON Ob­ject

{
   notRemoved: Array // If any users couldn't be removed, thats noted here.
}
Ex­am­ple
var group = arcgis.group(id)
.then(function (group) {
  return group.removeUsers(['userOne', 'userTwo'])
})
.then(function (confirmation) {
  console.log(confirmation)
})

group.ad­dUsers

Users can be added to a group. The groups ad­min­is­tra­tors and owner can add any user to the group. Mem­bers with­out this ac­cess can only add other mem­bers within the same or­ga­ni­za­tion to the group.

Params: Ar­ray of user­name strings

Re­turns: Promise that re­solves to a con­fir­ma­tion JSON Ob­ject

{
  success: true,
  groupId: id
}
Ex­am­ple
var group = arcgis.group(id)
.then(function (group) {
  return group.addUsers(['userOne', 'userTwo'])
})
.then(function (confirmation) {
  console.log(confirmation)
})

group.in­vi­teUsers

Users can be in­vited to join a group. This method sends an email to the ad­dress on record for the users given. All users in a group can in­vite other users.

Params: JSON Op­tions ob­ject

You can­not put an ar­bi­trary num­ber of min­utes in for ex­pi­ra­tion. It must be one of the val­ues in de­scrip­tion.

Op­tions De­fault De­scrip­tion
users [] Users to in­vite to group via email
role group_mem­ber’ group_mem­ber’ or group_ad­min’
ex­pi­ra­tion 1440 Ex­pi­ra­tion date on the in­vi­ta­tion can be set for one day, three days, one week, or two weeks, in min­utes.

Re­turns: Promise that re­solves to a con­fir­ma­tion JSON Ob­ject

{
  success: true,
  groupId: id
}
Ex­am­ple
var group = arcgis.group(id)
.then(function (group) {
  return group.inviteUsers({users: ['userOne', 'userTwo']})
})
.then(function (confirmation) {
  console.log(confirmation)
})

group.join

Cre­ates a re­quest to join a group for the cur­rently au­then­ti­cated user.

Re­turns Promise that re­solves to a con­fir­ma­tion JSON Ob­ject

{
  success: true,
  groupId: id
}
Ex­am­ple
arcgis.group(id)
.then(function (group) {
  return group.join()
})
.then(function (confirmation) {
  console.log(confirmation)
})

group.leave

Re­moves the cur­rently au­then­ti­cated user from the group.

Re­turns Promise that re­solves to a con­fir­ma­tion JSON Ob­ject

{
  success: true,
  groupId: id
}
Ex­am­ple
arcgis.group(id)
.then(function (group) {
  return group.leave()
})
.then(function (confirmation) {
  console.log(confirmation)
})

group.change­Owner

If you are an org ad­min, you can al­ways per­form this if you are a mem­ber of the group. Oth­er­wise, only ad­mins can do this maybe?

Changes to owner to a spec­i­fied user­name.

Params: String of a User­name

Re­turns: Promise that re­solves to a con­fir­ma­tion JSON Ob­ject.

{
  success: true,
  groupId: id
}
Ex­am­ple
arcgis.group(id)
.then(function (group) {
  return group.changeOwner(username)
})
.then(function (confirmation) {
  console.log(confirmation)
})

group.delete

Deletes the group. This does not delete con­tent or users, just the group that ag­gre­gates them. This is per­ma­nent.

Re­turns Promise that re­solves to a JSON con­fir­ma­tion Ob­ject

{
  success: Boolean,
  groupId: String
}
Ex­am­ple
arcgis.group(id)
.then(function (group) {
  return group.delete()
})
.then(function (confirmation) {
  console.log(confirmation)
})

group.cre­ate

Cre­at­ing a new group is a lit­tle dif­fer­ent than the other group meth­ods - one does not pass in a group Id, so it can be called off group im­me­di­ately.

Params: JSON Op­tions ob­ject

Op­tions De­fault De­scrip­tion
ti­tle none String, Name of the group
de­scrip­tion none String, De­scrip­tion of the group
sum­mary none String, > 256 char­ac­ter sum­mary
tags none Ar­ray, tags for group
ac­cess pri­vate’ String. pri­vate’, pub­lic’, or org’
isViewOnly false Boolean. Can items be added to the group?
isIn­vi­ta­tionOnly false Boolean. Can users join the group with­out an in­vi­ta­tion?
Ex­am­ple:
var options = {
  title: 'My New Group',
  description: 'This group is both new and mine',
  tags: ['my', 'new', 'cool', 'group'],
  access: 'public'
}
arcgis.group.create(options)
.then(function (newGroup) {
  console.log(newGroup)
})

item

Item is a generic func­tion that de­ter­mines the type of item, and adds the ap­pro­pri­ate meth­ods from the func­tions be­low. If you know your item type, you can call the ap­pro­pri­ate func­tion be­low di­rectly.

Item cre­ates an ob­ject that has the de­tails and in­ter­ac­tive meth­ods of an item in the plat­form. All items share a set of com­mon meth­ods, doc­u­mented be­low. Spe­cific item types have ad­di­tional meth­ods, as doc­u­mented in layer, map, application, and file.

Params: String of an Item ID.

Re­turns: Promise that re­solves JSON Ob­ject with item in­for­ma­tion and meth­ods.

{
  access: String,
  accessInformation: String,
  appCategories: Array,
  avgRating: Number,
  banner: String,
  commentsEnabled: Boolean.
  created: Date.
  culture: String,
  description: String,
  documentation: String,
  extent: Array,
  favorite: Boolean
  groups: Array
  id: String,
  itemControl: String
  largeThumbnail: String,
  licenseInfo: String
  listed: Boolean,
  modified: Date,
  name: String,
  numComments: Number,
  numRatings: Number,
  numViews: Number,
  owner: String,
  ownerFolder: String,
  properties: String?,
  protected: Boolean,
  screenshots: Array,
  size: Number,
  snippet: String,
  spatialReference: String,
  tags: Array,
  thumbnail: String,
  title: String,
  type: String,
  typeKeywords: Array,
  url: String,
  update: Function,          // Updates information
  rate: Function,            // Sets a rating
  favorite: Function,        // Adds to favorites
  duplicate: Function,       // Creates a copy, with options
  folder: Function,          // Moves to a folder
  changeOwner: Function,     // Changes owner
  deleteProtected: Function, // Prevents deletion
  relatedItems: Function,    // Gets related items
  permissions: Function,     // Sets permissions
  delete: Function,          // Deletes item
  // Additional methods per type, documented below
}
Ex­am­ple
arcgis.item(itemId)
.then(function (item) {
  console.log(item)
})

item.data

Get the data con­tent of the item such as WebMap or App con­fig­u­ra­tion.

Params: String of an Item ID.

Re­turns: Promise that re­solves JSON Ob­ject with item data.

Ex­am­ple
arcgis.item(itemId)
.then(function (item) {
  return item.data()
})
.then(function (data) {
  console.log(data)
})

item.cre­ate

Cre­ates a new Item and op­tional data

Params: JSON Op­tions ob­ject

Op­tions De­fault De­scrip­tion
ti­tle none String. Name of the group
de­scrip­tion none String. De­scrip­tion of the group
snip­pet none String. > 256 char­ac­ter sum­mary
tags none Ar­ray. tags for group
url none String. Web URI
data none String. Data con­tent such as WebMap JSON or App con­fig­u­ra­tion
li­cen­se­Info none String. ac­cess and us­age per­mis­sions or con­straints
thumb­nail none String. URL to a thumb­nail
ex­tent none String. min­i­mum bound­ing ex­tent
type none String. Type of item from all Por­tal types
Ex­am­ple:
var options = {
  title: 'My New Item',
  description: 'This item is both new and mine',
  tags: ['my', 'new', 'cool', 'item'],
  type: 'Web Mapping Application',
  owner: 'myuser'
}
arcgis.item.create(options)
.then(function (newItem) {
  console.log({'id': newItem.id, 'title': newItem.title})
})

item.up­date

Up­dates the in­for­ma­tion for an item.

Pa­ra­me­ters: JSON Ob­ject of Op­tions

Op­tions Type De­scrip­tion
ti­tle String Hu­man read­able ti­tle
snip­pet String <= 256 char­ac­ter sum­mary
de­scrip­tion String Longer de­scrip­tion
tags Ar­ray Ar­ray of tags
ex­tent Ar­ray [[lat, long], [lat, long]]
li­cen­se­Info String Some­thing?
ac­cess­In­for­ma­tion String Some­thing?

Re­turns: Promise that re­solves to the up­dated item

Ex­am­ple
arcgis.item(itemId)
.then(function (item) {
  return item.update({title: 'A New Hope'})
})
.then(function (item) {
  console.log(item)
})

item.per­mis­sions

In this case, pri­vate’ means that the only the user and ad­mins in that users org can view the item.

Up­dates the per­mis­sions for the item, ei­ther user only, or­ga­ni­za­tion, or pub­lic, and what groups have ac­cess to the item.

Params: Op­tions ob­ject

Op­tions Type De­scrip­tion
ac­cess String pri­vate’, org’, pub­lic’
group Ar­ray Group id’s to al­low ac­cess

Re­turns: Promise that re­solves to the up­dated item

Ex­am­ple

arcgis.item(itemId)
.then(function (item) {
  options = {
    access: 'private',
    groups: [
      group1id,
    group2id
    ]
  }
  return item.permissions(options)
})
.then(function (item) {
  console.log(item)
}

item.rate

A user can­not rate their own item.

Items can be rated by users. These rat­ings are tracked, and an av­er­age rat­ing is stored with the item. Users can change their rat­ing of an item at any time. As­so­ci­ates a rat­ing with the cur­rently au­then­ti­cated user.

Params: Num­ber, be­tween 0 and 5

Re­turns: Promise that re­solves to the up­dated item

Ex­am­ple
arcgis.item(itemId)
.then(function (item) {
  return item.rate(5)
})
.then(function (item) {
  console.log(item)
})

item.is­Fa­vorite

Check­ing if an item is cur­rently in the your fa­vorites group takes a cou­ple of ex­tra calls, so we don’t re­turn that with the item it­self.

Checks to see if an item is in the users fa­vorite items’ group.

Re­turns: Promise that re­solves to a boolean

Ex­am­ple
arcgis.item(itemId)
.then(function (item) {
  return item.isFavorite()
})
.then(function (isFavorite) {
  console.log(isFavorite)
})

item.fa­vorite

A users favorites are a group that only that user is a mem­ber of. Pre­sum­ably other users can be added to this. In most in­ter­faces, this group is ex­cluded from the list of other groups.

This method adds and re­moves an item from the users fa­vorite items’ group.

Params: Boolean

Re­turns: Promise that re­solves to the up­dated item

Ex­am­ple
arcgis.item(itemId)
.then(function (item) {
  return item.favorite(true)
})
.then(function (item) {
  console.log(item)
})

item.groups

An item be­ing in a group is of­ten re­ferred to as be­ing shared with’ that group.

Items can be placed in one or more groups. This call de­ter­mines what groups that item is a part of. This only re­turns groups that you can see - mean­ing it won’t re­turn other users fa­vorite items’ groups.

Re­turns: Promise that re­solves to an ar­ray of group ob­jects.

Ex­am­ple:
arcgis.item(itemId)
.then(function (item) {
  return item.groups()
})
.then(function (groups) {
  console.log(groups)
})

item.change­Owner

If the per­mis­sions on the item are set to pri­vate, this ac­tion could re­move the item from your view en­tirely. This can­not be un­done un­less your user has ad­min per­mis­sions.

Re­as­signs the item to a new user. This will re­move the item from the con­tent of the orig­i­nal user, and add it to the con­tent of the new user.

Params: String of a user­name

Re­turns: Promise that re­solves to the up­dated item

Ex­am­ple
arcgis.item(itemId)
.then(function (item) {
  return item.changeOwner(username)
})
.then(function (item) {
  // Will return an error if you no longer have permissions to view the item.
  console.log(item)
}

item.deletePro­tected

Sets a boolean on the item that al­lows the item to be deleted.If set to true, this needs to be changed to false be­fore item.delete will func­tion.

Params: Boolean

Re­turns: Promise that re­solves to the up­dated item

Ex­am­ple
arcgis.item(itemId)
.then(function (item) {
  return item.deleteProtected(true)
})
.then(function (item) {
  console.log(item)
}

item.delete

For real, once you do this, you can’t undo it.

Deletes the item. Per­ma­nently. For ever. Se­ri­ously. Keep this from be­ing to ter­ri­fy­ing on pro­duc­tion items with item.deleteProtected.

Re­turns: Promise that re­solves to an ob­ject with a con­fir­ma­tion.

Ex­am­ple
arcgis.item(itemId)
.then(function (item) {
  return item.delete()
})
.then(function (confirmation) {
  console.log(confirmation)
}

layer

For ex­am­ple, if you know your item id is for a layer, you can call arcgis.layer(itemid). If aren’t sure, than arcgis.item(itemid) will check, and re­turn the ap­pro­pri­ate type.

Layer re­turns an item with ad­di­tional meth­ods.

Params: String of an Item ID.

Re­turns: Promise that re­solves JSON Ob­ject with item in­for­ma­tion and meth­ods.

{
  data: Function,          // Geographic data in the layer
  export: Function,        // Exports to defined format
  generateTiles: Function, // Creates a tile layer
  usage: Function          // Reports credits, requests
}
Ex­am­ple
arcgis.layer('layerId')
.then(function (layer) {
  console.log(layer)
})

layer.data

Lay­ers have ge­o­graphic data - a set of fea­tures with prop­er­ties. This method re­turns that ge­o­graphic data as … some­thing?

Re­turns: Promise that re­solves to a JSON Ob­ject

{
  features: [
    {
      attributes: Object,
      geometry: Object
    }
  ],
  fields: [
    {
      ???: ???
    }
  ],
  geometryType: String,
  globalIdFieldName: String,
  objectIdFieldName: String,
  spatialReference: {
  latestWkid: String,
  wkid: String
  }
}
Ex­am­ple:
arcgis.layer(itemId)
.then(function (layer) {
  return layer.data()
})
.then(function (data) {
  console.log(data)
}

map

These map func­tions are largely as­pi­ra­tional.

Map re­turns an item with ad­di­tional meth­ods.

{
  layers: Function,       // Lists the layers
}

map.lay­ers

Re­turns all the lay­ers on the map, in or­der from back to front. Can also be used to re­order lay­ers on the map.

Re­turns Promise that re­solves to an Ob­ject

{
  authoringApp: String,
  authoringAppVersion: String,
  baseMap: {
    baseMapLayers: [
      {
        id: String,
        layerType: String,
        opacity: Number,
        url: String,
        visibility: Boolean,
        length: Number,
        title: String
      }
    ]
  },
  operationalLayers: [
    {
      id: String,
      itemId: String,
      layerType: String,
      opacity: Number,
      popupInfo: Object,
      title: String,
      url: String,
      visibility: Boolean
    }
  ],
  spatialReference: {
    latestWkid: String,
    wkid: String
  }
}
Ex­am­ple:
arcgis.map(itemId)
.then(function (map) {
  return map.layers()
})
.then(function (layers) {
  console.log(layers)
})

ap­pli­ca­tion

Application re­turns an item with ad­di­tional meth­ods.

{
  register: Function,     // Registers app with the portal
  getOAuth: Function,     // Gets oAtuh data for app
  getToken: Function      // Creates a token for the app
}

ap­pli­ca­tion.reg­is­ter

Reg­is­ters the ap­pli­ca­tion with the plat­form, pro­vid­ing ac­cess to oAuth meth­ods.

Re­turns: Promise that re­solves to the up­dated application

Ex­am­ple
arcgis.application(appid)
.then(function (application) {
  return application.register()
})
.then(function (application) {
  console.log(application)
})

ap­pli­ca­tion.getOAuth

Gets the ap­pli­ca­tions oAuth in­for­ma­tion, in­clud­ing client id and se­cret.

Re­turns: Promise that re­solves to the oAuth in­for­ma­tion ob­ject.

Ex­am­ple
arcgis.application(appid)
.then(function (application) {
  return application.getOAuth()
})
.then(function (oAuth) {
  console.log(oAuth)
})

ap­pli­ca­tion.get­To­ken

Gets a valid to­ken from the app. This to­ken can used to ac­cess ser­vices.

Re­turns: Promise that re­solves to the to­ken

Ex­am­ple
arcgis.application(appid)
.then(function (application) {
  return application.getToken()
})
.then(function (token) {
  console.log(token)
})

file

File re­turns an item with ad­di­tional meth­ods.

{
  publish: Function, // Turns the file into a layer
  download: Function // Downloads the file
}

file.pub­lish

If the file con­tains ge­o­graphic data - csv, geo­j­son, shape­file, ge­o­data­base, etc - it can be turned into a layer that you can use on maps. Re­sults in a con­fir­ma­tion ob­ject that con­tains in­for­ma­tion on the new layer.

Re­turns a Job ID in the con­fir­ma­tion, which can be used to pole the ser­vice to see if the layer has fin­ished be­ing cre­ated.

Re­turns Promise that re­solves to an ob­ject with ar­ray of processes

The serviceItemId key is the item ID for the newly cre­ated layer.

{
  services: [
    {
      encodedServiceURL: String,
      jobId: String,
      serviceItemId: String,
      serviceurl: String,
      size: Number,
      type: String
  }
}

file.down­load

Down­loads the file.