1010data API Reference Manual (212) 405.1010 | [email protected] | Follow: @1010data | www.1010data.com 1010data API Reference Manual | Contents | 2 Contents 1010data Application Program Interface...................................................4 login (Start the session)...................................................................................................................... 6 logout (End the session)..................................................................................................................... 7 dir (List the contents of a directory)....................................................................................................7 listdir (List the contents of a directory)............................................................................................... 9 getdir (Get information about a directory).........................................................................................12 putdir (Modify directory information)..................................................................................................14 mkdir (Create a directory)................................................................................................................. 16 gettab (Get information about a table)..............................................................................................17 tabinfo (Get information about a table)............................................................................................. 19 puttab (Modify table information)...................................................................................................... 21 query (Apply a query to a table).......................................................................................................23 getdata (Get the results of a query)................................................................................................. 25 querydata (Apply a query to a table and get results)....................................................................... 28 savefile (Save query results as a file).............................................................................................. 29 savetable (Save query results as a table)........................................................................................ 31 upload (Upload table)........................................................................................................................ 33 merge (Merge table)..........................................................................................................................35 droptable (Delete table).....................................................................................................................36 dropdir (Delete directory)...................................................................................................................37 drop (Delete several tables or folders)............................................................................................. 38 move (Move several tables or folders)............................................................................................. 40 order (Order the items in a directory)............................................................................................... 41 clear (Clear the cache)..................................................................................................................... 42 refresh (Refresh)............................................................................................................................... 43 session (Set session parameters).....................................................................................................44 PowerLoader Transactions.......................................................................47 addtab (Load a large table).............................................................................................................. 47 status (Status of the addtab API)..................................................................................................... 50 convert (Convert a legacy spec)....................................................................................................... 51 edittab (Edit a table)..........................................................................................................................53 validate (Validate a table)................................................................................................................. 54 Table Tree...................................................................................................58 <cols> (Metadata for all columns).....................................................................................................58 <data> (Table data)...........................................................................................................................59 <sdesc> (Short description of a table)..............................................................................................59 <ldesc> (Long description of a table)............................................................................................... 59 <link> (Link header).......................................................................................................................... 60 <links> (Top-level wrapper for links).................................................................................................61 <maxdown> (Download limit)............................................................................................................ 61 <segmentation> (Specify the segmentation of a table).................................................................... 62 <table> (Top-level wrapper for table tree)........................................................................................ 62 <td> (One cell of data in a table)..................................................................................................... 63 <th> (Meta information for one column)........................................................................................... 63 <title> (Table title)............................................................................................................................. 64 <tr> (Data for one row)..................................................................................................................... 65 © 2014 1010data, Inc. All rights reserved. 1010data API Reference Manual | Contents | 3 Users Tree.................................................................................................. 66 <users> (Top-level wrapper for users tree)...................................................................................... 66 <user> (User entry)........................................................................................................................... 67 Field Data Types........................................................................................68 Field Format Types................................................................................... 69 Deprecated Transactions.......................................................................... 70 rmdir (Delete a directory).................................................................................................................. 70 rmtab (Delete a table)....................................................................................................................... 71 prelink (Prelink tables).......................................................................................................................72 timeseries (Merge tables using time series)..................................................................................... 73 © 2014 1010data, Inc. All rights reserved. 1010data API Reference Manual | 1010data Application Program Interface | 4 1010data Application Program Interface The 1010data Application Program Interface (API) is a facility whereby a client application running on a user's machine can access and query data on the 1010data database servers. This allows for unlimited customization of the application while taking advantage of 1010data's database management services and fast database engine. The API uses HTTP and XML and is compatible with any client application written in a language that supports HTTP transactions (such as Java, Visual Basic, C++, Python and PERL.) Prerequisites A working knowledge of the 1010data database service and user interface is assumed. In particular, the reader is expected to be familiar with table operations (e.g. select rows, sort, tabulate) and the 1010data macro language. To use the API, a valid 1010data username and password is required and the username must be authorized to use the API. Transactions Transactions through the API are a series of HTTP(S) POSTs. The client-to-server message consists of a header followed by contents, where the two are separated by "\r\n\r\n". Among other things the header must contain a query string that specifies the type of API transaction and certain information that identifies the user. The contents, in XML format, contains the transaction details and possibly other data. (For some transactions, the contents may be empty.) An example of such a message is as follows: POST /cgi-bin/gw.k? api=query&apiversion=3&uid=myid&pswd=Aiynnsewxhck&sid=1748453843 http/1.0 Content-Type: text/xml Content-Length: 296 <in> <name>pub.demo.weather.hourly95</name> <ops> <sel value="(id=94789)"/> <tabu label="Average temperature and humidity in NYC" breaks="date"> <tcol source="temp" fun="avg" label="Average`Dry Bulb`Temp`(Celsius)"/> <tcol source="hum" fun="avg" label="Average`Relative`Humidity`(%)"/> </tabu> </ops> </in> Note that the query string on the first line specifies that this is a "query" transaction and includes the user's username (uid) and password (pswd). The message must always contain a lowercase "http/1.0", "https/1.0" , "http/1.1" or "https/1.1" and the Content-Length must be set to the length (number of characters) of the XML contents. The response from the server is also in the form of a header followed by XML contents. An example of such a message is as follows: HTTP/1.1 200 OK Date: Sun, 23 Dec 2001 04:27:43 GMT Server: Apache/1.3.9 (OpenSA) (Win32) mod_ssl/2.4.2 OpenSSL/0.9.4 Content-Length: 251 Connection: close Content-Type: text/xml <out> <rc>0</rc> <msg>query successful</msg> <nrows>365</nrows> <table> <cols> <th name="date" type="i" format="type:date"> Date </th> 1010data API Reference Manual | 1010data Application Program Interface | 5 <th name="t0" type="f" format="type:num;width:6;dec:2"> Average Dry Bulb Temp (Celsius) </th> <th name="t1" type="f" format="type:num;width:6;dec:2"> Average Relative Humidity (%) </th> </cols> <data/> </table> </out> The information in the contents depends on the type of transaction, but it always includes the following two elements: <rc> return code (0 means OK, 1-39 means error) </rc> <msg> message </msg> The error codes are described in detail in the next section. Error Codes A nonzero value in the <rc> tag indicates there was an error in processing your transaction. The error can be related to the syntax or semantics of the XML content submitted to the server. The codes are designed to give programs the ability to gracefully deal with errors without having to interpret the contents of the <msg> tag. The universe of possible error codes is as follows: 0 Success (no error) 1 Unclassified error 2 XML error 3 Missing user identification 4 Invalid user identification 5 Already logged in 6 Missing transaction type 7 Invalid transaction type 8 Missing element 9 Invalid element value 10 Invalid element contents 11 Missing attribute 12 Invalid attribute name 13 Invalid attribute value 14 Invalid directory name 15 No such directory 16 Invalid table name 17 No such table 18 No such directory or table 19 Directory already exits 20 Table already exits 21 No query specified 22 Not currently implemented for Quick Queries 23 Too many values 24 Empty table 25 Problem saving table 26 Cannot save into 'uploads' directory 27 Problem deleting table 28 Problem saving file 29 Duplicate column names 30 Duplicate table names 31 No FTP permission 32 Not enough available space left in your account. 33 Problem moving table or directory 34 Problem modifying table or directory attributes 35 Not Logged in. 36 <cols> contains columns that do not appear in result 37 You do not own the specified group 1010data API Reference Manual | 1010data Application Program Interface | 6 38 System is busy 39 You are not at an authorized IP address 41 1010data is unavailable The query string and XML input and output for each transaction are described in detail in the next section. login (Start the session) The login transaction starts a session and must precede all other transactions. Query String The query string in the HTTP header must contain the following parameters: Connection String Value Variable api login apiversion 3 uid [USERNAME] pswd [PASSWORD] kill yes or no (optional) If kill=no and a session already exists for the specified username (i.e., the user is already logged in), an error message is returned (see "XML Response from Server" below). If kill=yes or if kill is not specified, a new session is started and any existing session is logged out. Query String Example api=login&apiversion=3&uid=myid&pswd=mypswd&kill=yes XML Input to Server No XML input required. XML Response from Server The session ID and encrypted password are used in subsequent transactions. If the login is not successful, only the return code and error message are returned. A successful result contains the following elements: XML Element Returned Description of Returned Element Content <rc> Return code <msg> Message <sid> Session ID <pswd> Encrypted password XML Response Example <out> <rc>0</rc> <sid>1748453843</sid> <pswd>Aiynnsewxhck</pswd> <msg>Last login was: 2001-12-27 01:01:46</msg> 1010data API Reference Manual | 1010data Application Program Interface | 7 </out> logout (End the session) The logout transaction ends the session. Query String The query string in the HTTP header must contain the following parameters: Connection String Value Variable api logout apiversion 3 uid [USERNAME] pswd [ENCRYPTED PASSWORD] - returned from the login transaction sid [SESSION ID] (optional) - returned from the login transaction kill yes or no (optional) If kill=yes and a query is processing, the query will be terminated and the session will logout as usual. Query String Example api=logout&apiversion=3&uid=myid&pswd=Aiynnsewxhck&sid=1748453843 XML Input to Server No XML input required. XML Response from Server A successful logout produces the following result: <out> <rc>0</rc> <msg>Logged out</msg> </out> dir (List the contents of a directory) The dir transaction returns a listing of the contents of a directory (folder). Query String The query string in the HTTP header must contain the following parameters: Connection String Value Variable api dir apiversion 3 uid [USERNAME] 1010data API Reference Manual | 1010data Application Program Interface | 8 Connection String Value Variable pswd [ENCRYPTED PASSWORD] - returned from the login transaction sid [SESSION ID] (optional) - returned from the login transaction Query String Example api=dir&apiversion=3&uid=myid&pswd=Aiynnsewxhck&sid=1748453843 XML Input to Server The specifications must contain the following element: XML Element To Send Description of Sent Element Content <name> The full path to the directory in the 1010data database hierarchy. In general, a path has the form: directory1.directory2.....directoryn.thisdirectory (similar to a Windows or Unix file-system path but with dots instead of slashes) XML Input Example <in><name>mycompany.folder</name></in> XML Response from Server A successful result contains the following elements: XML Element Returned Description of Returned Element Content <rc> Return code <msg> Message <table> Directory listing The directory listing is returned in the form of a table (see Table Tree on page 58) with one row for each entry and two columns. The first column contains the name of the entry and the second indicates whether it is a directory (dir) or a table (tab). In the event of an error, only the return code and error message are returned. XML Response Example <rc>0</rc> <msg>dir successful</msg> <table> <cols> <th name="name" type="a">name</th> <th name="type" type="a">type</th> <th name="title" type="a">title</th> </cols> <data> <tr> <td>mycompany.folder.table1</td> <td>tab</td> <td>table1</td> 1010data API Reference Manual | 1010data Application Program Interface | 9 </tr> <tr> <td>mycompany.folder.table2</td> <td>tab</td> <td>table2</td> </tr> <tr> <td>mycompany.folder.table3</td> <td>tab</td> <td>table3</td> </tr> <tr> <td>mycompany.folder.table4</td> <td>tab</td> <td>table4</td> </tr> </data> </table> listdir (List the contents of a directory) The listdir transaction returns a listing of the contents of a directory (folder) and provides more information than the dir transaction. Query String The query string in the HTTP header must contain the following parameters: Connection String Value Variable api listdir apiversion 3 uid [USERNAME] pswd [ENCRYPTED PASSWORD] - returned from the login transaction sid [SESSION ID] (optional) - returned from the login transaction Query String Example api=listdir&apiversion=3&uid=myid&pswd=Aiynnsewxhck&sid=1748453843 XML Input to Server The specifications must contain the following elements: XML Element To Send Description of Sent Element Content <name> The full path to the directory in the 1010data database hierarchy. In general, a path has the form directory1.directory2.....directoryn.thisdirectory (similar to a Windows or Unix file-system path but with dots instead of slashes.) To list the contents of the top level directory ("All Databases"), leave the name blank ("<name></name>" or "<name/>"). <include> (optional) An optional filter to reduce the number of attributes returned in order to reduce transmission size. Provide a list of <name> elements containing the attributes you 1010data API Reference Manual | 1010data Application Program Interface | 10 XML Element To Send Description of Sent Element Content want in the results. Also include a mode attribute containing 1 or 2 depending on whether operation should apply to parents as well as children, or children only respectively. XML Input Example <in> <name>pub.demo.weather</name> <include mode=1><name>id</name> <name>users</name> </include> </in> XML Response from Server A successful response from the server contains the following elements: XML Element To Send Description of Sent Element Content <rc> The return code. <msg> The message from the server. <dir> Directory information. XML Response Example A successful listdir produces the following result: <dir id="36011" name="pub.demo.weather" title="Weather" sdesc="" ldesc="" type="DIR" secure="0" own="0" owner="sandy2" upload="0" update="2034-12-31 19:00:00" gif="" favorite="0" numchild="9"> <parents> <dir id="0" name="" title="All Databases" sdesc="" ldesc="" type="DIR" secure="0" own="0" owner="" upload="0" update="2034-12-31 19:00:00" gif="" favorite="0" numchild="9"/><dir id="2" name="pub" title="Published Data" sdesc="" ldesc="" type="DIR" secure="0" own="0" owner="sandy2" upload="0" update="2034-12-31 19:00:00" gif="" favorite="1" numchild="4"/><dir id="36009" name="pub.demo" title="Demo" sdesc="" ldesc="" type="DIR" secure="0" own="0" owner="sandy2" upload="0" update="2034-12-31 19:00:00" gif="" favorite="0" numchild="4"/> </parents> <children> <tab id="170" name="pub.demo.weather.stations" type="REAL" display="TABLE" report="0" chart="0" title="Stations" sdesc="Station location" ldesc="" link="stations" rows="262" bytes="14064" segs="1" tstat="0" access="1" secure="0" maxdown="" own="0" owner="sandy2" update="2007-02-26 19:13:37" favorite="0"/ ><tab id="171" name="pub.demo.weather.pwcodes" type="REAL" display="TABLE" report="0" chart="0" title="Present Weather Codes" sdesc="" ldesc="" link="pwcodes" rows="83" bytes="1456" segs="1" tstat="0" access="1" secure="0" maxdown="" own="0" owner="sandy2" update="2007-02-26 19:13:37" favorite="0"/><tab id="172" name="pub.demo.weather.hourly" type="REAL" display="TABLE" report="0" chart="0" 1010data API Reference Manual | 1010data Application Program Interface | 11 title="Hourly U.S. Weather" sdesc="Hourly United States weather observations (1990-1995)" ldesc="This table contains hourly observations at 262 weather stations over a six year period (1990-1995). Each row contains the data for a particular station at a particular hour of a particular day. (Note that there are 262 stations and 2191 days in the period 1990-1995, so there should be 13,777,008 rows (262 stations x 2191 days x 24 hours) in this table. There are actually somewhat fewer because the data begins with 1:00 AM on 1/1/90 and ends with 11:00 PM on 12/31/95, so there is one hour missing.) Each station is identified by an ID that corresponds to the ID in the "Stations" table." link="" rows="13776746" bytes="1558716664" segs="4" tstat="0" access="1" secure="0" maxdown="" own="0" owner="sandy2" update="2001-01-04 21:33:38" favorite="0"/ ><tab id="173" name="pub.demo.weather.hourly95" type="REAL" display="TABLE" report="0" chart="0" title="Hourly U.S. Weather (1995)" sdesc="Hourly United States weather observations" ldesc="This table contains hourly observations at 262 weather stations over a one year period. Each row contains the data for a particular station at a particular hour of a particular day. Each station is identified by an ID that corresponds to the ID in the Stations table." link="weather" rows="2294858" bytes="266215904" segs="4" tstat="0" access="1" secure="0" maxdown="" own="0" owner="sandy2" update="2007-05-17 08:41:42" favorite="0"/ ><tab id="73725" name="pub.demo.weather.hourly90" type="REAL" display="TABLE" report="0" chart="0" title="Hourly U.S. Weather (1990)" sdesc="Hourly United States weather observations" ldesc="This table contains hourly observations at 262 weather stations over a one year period. Each row contains the data for a particular station at a particular hour of a particular day. Each station is identified by an ID that corresponds to the ID in the Stations table." link="weather" rows="2295120" bytes="266246296" segs="4" tstat="0" access="1" secure="0" maxdown="" own="1" owner="dhorowitz" update="2007-05-17 08:41:42" favorite="0" users=""/><tab id="73726" name="pub.demo.weather.hourly91" type="REAL" display="TABLE" report="0" chart="0" title="Hourly U.S. Weather (1991)" sdesc="Hourly United States weather observations" ldesc="This table contains hourly observations at 262 weather stations over a one year period. Each row contains the data for a particular station at a particular hour of a particular day. Each station is identified by an ID that corresponds to the ID in the Stations table." link="weather" rows="2295120" bytes="266246296" segs="4" tstat="0" access="1" secure="0" maxdown="" own="1" owner="dhorowitz" update="200705-17 08:41:42" favorite="0" users=""/><tab id="73727" name="pub.demo.weather.hourly92" type="REAL" display="TABLE" report="0" chart="0" title="Hourly U.S. Weather (1992)" sdesc="Hourly United States weather observations" ldesc="This table contains hourly observations at 262 weather stations over a one year period. Each row contains the data for a particular station at a particular hour of a particular day. Each station is identified by an ID that corresponds to the ID in the Stations table." link="weather" 1010data API Reference 14 Transaction Details rows="2301408" bytes="266975704" segs="4" tstat="0" access="1" secure="0" maxdown="" own="1" owner="dhorowitz" update="2007-05-17 08:41:42" favorite="0" users=""/><tab id="73728" name="pub.demo.weather.hourly93" type="REAL" display="TABLE" report="0" chart="0" title="Hourly U.S. Weather (1993)" sdesc="Hourly United States weather observations" ldesc="This table contains 1010data API Reference Manual | 1010data Application Program Interface | 12 hourly observations at 262 weather stations over a one year period. Each row contains the data for a particular station at a particular hour of a particular day. Each station is identified by an ID that corresponds to the ID in the Stations table." link="weather" rows="2295120" bytes="266246296" segs="4" tstat="0" access="1" secure="0" maxdown="" own="1" owner="dhorowitz" update="200705-17 08:41:42" favorite="0" users=""/><tab id="73729" name="pub.demo.weather.hourly94" type="REAL" display="TABLE" report="0" chart="0" title="Hourly U.S. Weather (1994)" sdesc="Hourly United States weather observations" ldesc="This table contains hourly observations at 262 weather stations over a one year period. Each row contains the data for a particular station at a particular hour of a particular day. Each station is identified by an ID that corresponds to the ID in the Stations table." link="weather" rows="2295120" bytes="266246296" segs="4" tstat="0" access="1" secure="0" maxdown="" own="1" owner="dhorowitz" update="2007-05-17 08:41:42" favorite="0" users=""/> </children> </dir> getdir (Get information about a directory) The getdir transaction returns meta information of a directory (folder.) Query String The query string in the HTTP header must contain the following parameters: Connection String Value Variable api getdir apiversion 3 uid [USERNAME] pswd [ENCRYPTED PASSWORD] - returned from the login transaction sid [SESSION ID] (optional) - returned from the login transaction Query String Example api=getdir&apiversion=3&uid=myid&pswd=Aiynnsewxhck&sid=1748453843 XML Input to Server The specifications must contain the following elements: XML Element To Send Description of Sent Element Content <name> The full path to the directory in the 1010data database hierarchy. In general, a path has the form directory1.directory2.....directoryn.thisdirectory (similar to a Windows or Unix file-system path but with dots instead of slashes.) To list the contents of the top level directory ("All Databases"), leave the name blank ("<name></name>" or "<name/>"). 1010data API Reference Manual | 1010data Application Program Interface | 13 XML Element To Send Description of Sent Element Content <include> (optional) An optional filter to reduce the number of attributes returned in order to reduce transmission size. Provide a list of <name> elements containing the attributes you want in the results. Also include a mode attribute containing 1 or 2 depending on whether operation should apply to parents as well as children, or children only respectively. XML Input Example <in><name>pub.demo.weather</name></in> XML Response from Server A successful response from the server contains the following elements: XML Element To Send Description of Sent Element Content <rc> The return code. <msg> The message from the server. <dir> Directory information. The directory meta data is returned as a series of attributes contained within the <dir> element. The attributes are as follows: XML Element To Send Description of Sent Element Content id The ID of a directory. name The full path of the directory. title The title of the directory as displayed in the UI. sdesc The short description of the directory. ldesc The long description of the directory. type The type of directory. Currently, there is only one directory type: dir. secure Is the directory marked as secure. Returns 0 or 1. own Is the API user the owner of the directory specified in the <name> element. Returns 0 or 1. owner Who is the owner of the directory? Returns the username. upload Can the API user create new items in the directory specified in the <name> element? Returns 0 or 1. update When was the directory created or its attributes last changed? gif The GIF file associated with the directory to be displayed in the UI favorite Is this directory marked as a favorite for the API user? Returns 0 or 1. uploaders Space separated list of users and groups who have permission to create tables or directories inside the directory. 1010data API Reference Manual | 1010data Application Program Interface | 14 XML Element To Send Description of Sent Element Content numchild How many visible items descend from the directory specified in the <name> element. XML Response Example A successful getdir produces the following result: <out> <rc>0</rc> <msg>getdir successful</msg> <dir id="36011" name="pub.demo.weather" title="Weather" sdesc="" ldesc="" type="DIR" secure="0" own="0" owner="sandy2" upload="0" update="2001-12-31 19:00:00" gif="" favorite="0" numchild="9"/> </out> putdir (Modify directory information) The putdir transaction modifies the meta information for a directory (folder). Query String The query string in the HTTP header must contain the following parameters: Connection String Value Variable api putdir apiversion 3 uid [USERNAME] pswd [ENCRYPTED PASSWORD] - returned from the login transaction sid [SESSION ID] (optional) - returned from the login transaction Query String Example api=putdir&apiversion=3&uid=myid&pswd=Aiynnsewxhck&sid=1748453843 XML Input to Server The specifications must contain the following elements: XML Element To Send Description of Sent Element Content <dir> The transmission to the 1010data server must be a <dir> element that contains the attributes described in the table below. Include the following attributes with the <dir> element: Note: Any attributes that are omitted will not be modified. 1010data API Reference Manual | 1010data Application Program Interface | 15 XML Element To Send Description of Sent Element Content id The ID of a directory. name The full path of the directory. title The title of the directory as displayed in the UI. sdesc The short description of the directory. ldesc The long description of the directory. secure Is the directory marked as secure. Returns 0 or 1. users Space separated list of users and groups who have permission to view the directory. owner Who is the owner of the directory? Returns the username. gif The GIF file associated with the directory to be displayed in the UI uploaders Space separated list of users and groups who have permission to create tables or directories inside the directory. XML Input Example <in><dir id="36011" name="pub.demo.newweather" title="New Weather" sdesc="" ldesc="" secure="0" /><in> XML Response from Server A successful response from the server contains the following elements: XML Element To Send Description of Sent Element Content <rc> The return code. <msg> The message from the server. <dir> Directory information. The directory meta data is returned as a series of attributes contained within the <dir> element. The attributes are as follows: XML Response Example A successful putdir produces the following result: <out> <rc>0</rc> <msg>putdir successful</msg> <dir id="36011" name="pub.demo.weather" title="Weather" sdesc="" ldesc="" type="DIR" secure="0" own="0" owner="sandy2" upload="0" update="2001-12-31 19:00:00" gif="" favorite="0" numchild="9"/> </out> 1010data API Reference Manual | 1010data Application Program Interface | 16 mkdir (Create a directory) The mkdir transaction creates a directory. The API will check the permission of the user and create the directory only if the user calling the transaction is authorized to create the directory in the parent folder. Query String The query string in the HTTP header must contain the following parameters: Connection String Value Variable api mkdir apiversion 3 uid [USERNAME] pswd [ENCRYPTED PASSWORD] - returned from the login transaction sid [SESSION ID] (optional) - returned from the login transaction Query String Example api=mkdir&apiversion=3&uid=myid&pswd=Aiynnsewxhck&sid=1748453843 XML Input to Server The specifications must contain the following elements: XML Element To Send Description of Sent Element Content <name> The full path to the directory in the 1010data database hierarchy. In general, a path has the form: directory1.directory2.....directoryn.thisdirectory (similar to a Windows or Unix file-system path but with dots instead of slashes) <users> Users authorized to browse the directory. See Users Tree on page 66 for the XML schema. <uploaders> Users authorized to add content to the directory. See Users Tree on page 66 for the XML schema. <title> The title of the directory. XML Input Example <in> <name>mycompany.folder.yearly</name> <users type=”list”> <user>user1</user> <user>user2</user> </users> <uploaders type=”list”> <user>user2</user> </users> <title>Yearly Data</title> 1010data API Reference Manual | 1010data Application Program Interface | 17 </in> XML Response from Server A successful mkdir produces the following result: <rc>0</rc> <msg>mkdir successful</msg> gettab (Get information about a table) The gettab transaction returns meta information of a table. Note that meta information does not include information about columns or contents of the table. Query String The query string in the HTTP header must contain the following parameters: Connection String Value Variable api gettab apiversion 3 uid [USERNAME] pswd [ENCRYPTED PASSWORD] - returned from the login transaction sid [SESSION ID] (optional) - returned from the login transaction Query String Example api=gettab&apiversion=3&uid=myid&pswd=Aiynnsewxhck&sid=1748453843 XML Input to Server The specifications must contain the following elements: XML Element To Send Description of Sent Element Content <name> The full path to the directory in the 1010data database hierarchy. In general, a path has the form directory1.directory2.....directoryn.thisdirectory (similar to a Windows or Unix file-system path but with dots instead of slashes.) To list the contents of the top level directory ("All Databases"), leave the name blank ("<name></name>" or "<name/>"). <include> (optional) An optional filter to reduce the number of attributes returned in order to reduce transmission size. Provide a list of <name> elements containing the attributes you want in the results. Also include a mode attribute containing 1 or 2 depending on whether operation should apply to parents as well as children, or children only respectively. XML Input Example <in><name>pub.demo.weather.hourly95</name></in> 1010data API Reference Manual | 1010data Application Program Interface | 18 XML Response from Server A successful response from the server contains the following elements: XML Element To Send Description of Sent Element Content <rc> The return code. <msg> The message from the server. <tab> Table information. The directory meta data is returned as a series of attributes contained within the <tab> element. The attributes are as follows: XML Element To Send Description of Sent Element Content id The ID of the table. name The full path of the table. title The title of the table as displayed in the UI. sdesc The short description of the table. ldesc The long description of the table. type The type of table. Can be one of – REAL, VIEW, PARAM, MERGED, UQ, TOLERANT. secure Is the directory marked as secure. Returns 0 or 1. own Is the API user the owner of the directory specified in the <name> element. Returns 0 or 1. owner Who is the owner of the directory? Returns the username. update When was the directory created or its attributes last changed? favorite Is this directory marked as a favorite for the API user? Returns 0 or 1. users Space separated list of users and groups who have permission to view the directory. display The output type of the table. Can be one of – TABLE, EXCEL, CHART, REPORT, TEXT, XML report Does the table or query have report specifications saved? Returns 0 or 1. chart Does the table or query have chart specifications saved? Returns 0 or 1. link A string to be spliced to column headers when linking in to other tables rows Number of rows in the table bytes Number of bytes utilized by the table segs Number of segments in the table tstat Is the table accessible for timeseries functions? Returns 0 or 1. access Is the table accessible. Is the table accessible. Returns 0 or 1. maxdown Limit to the number of rows a user can download for the table 1010data API Reference Manual | 1010data Application Program Interface | 19 If the table is a Query (type of VIEW, PARAM, MERGED or TOLERANT) then the tab element will contain an ops and dependencies element. Any dependencies on other tables (i.e., links, merges) are available in the <dependencies> element which contains a list of lists of tables references if the table is a QQ or Merged table. XML Response Example <out> <rc>0</rc> <msg>gettab successful</msg> <tab id="173" name="pub.demo.weather.hourly95" type="REAL" display="TABLE" report="0" chart="0" title="Hourly U.S. Weather (1995)" sdesc="Hourly United States weather observations" ldesc="This table contains hourly observations at 262 weather stations over a one year period. Each row contains the data for a particular station at a particular hour of a particular day. Each station is identified by an ID that corresponds to the ID in the Stations table." link="weather" rows="2294858" bytes="266215904" segs="4" tstat="0" access="1" secure="0" maxdown="" own="0" owner="sandy2" update="2007-05-17 08:41:42" favorite="0"/> </out> tabinfo (Get information about a table) The tabinfo transaction returns information about a table. Query String The query string in the HTTP header must contain the following parameters: Connection String Value Variable api tabinfo apiversion 3 uid [USERNAME] pswd [ENCRYPTED PASSWORD] - returned from the login transaction sid [SESSION ID] (optional) - returned from the login transaction Query String Example api=tabinfo&apiversion=3&uid=myid&pswd=Aiynnsewxhck&sid=1748453843 XML Input to Server The specifications must contain the following element: XML Element To Send Description of Sent Element Content <name> The full path to the table in the 1010data database hierarchy. In general, a path has the form: 1010data API Reference Manual | 1010data Application Program Interface | 20 XML Element To Send Description of Sent Element Content directory1.directory2.....directoryn.table (similar to a Windows or Unix file-system path but with dots instead of slashes) The name of a table can be determined by clicking Help > About this Table in the 1010data web interface. XML Input Example <in><name>pub.demo.weather.hourly95</name></in> XML Response from Server The session ID and encrypted password are used in subsequent transactions. If the login is not successful, only the return code and error message are returned. A successful result contains the following elements: XML Element Returned Description of Returned Element Content <rc> Return code <msg> Message <table> Information about the table The <table> element (see Table Tree on page 58) contains information about the table. It is equivalent to the table with zero rows of data (i.e., the <data> element is empty.) In the event of an error, only the return code and error message are returned. XML Response Example <out> <rc>0</rc> <msg>tabinfo successful</msg> <table name="pub.demo.weather.hourly95"> <title>Hourly U.S. Weather (1995)</title> <sdesc>Hourly United States weather observations</sdesc> <ldesc>This table contains hourly observations at 262 weather stations over a one year period. Each row contains the data for a particular station at a particular hour of a particular day. Each station is identified by an ID that corresponds to the ID in the Stations table.</ldesc> <link></link> <cols> <th name="id" type="i" format="type:nocommas;width:5"> Station ID</th> <th name="date" type="i" format="type:date"> Date</th> <th name="hour" type="i" format="type:num;width:4;dec:0"> Hour</th> <th name="asos" type="i" format="type:num;width:3;dec:0"> ASOS Flag</th> <th name="grad" type="i" format="type:num;width:6;dec:0"> Global Radiation (0.1 w/m2)</th> <th name="drad" type="i" format="type:num;width:6;dec:0"> Direct Radiation (0.1 w/m2)</th> <th name="tsky" type="i" format="type:num;width:3;dec:0"> Total Sky Cover</th> 1010data API Reference Manual | 1010data Application Program Interface | 21 <th name="osky" type="i" format="type:num;width:4;dec:0"> Opaque Sky Cover</th> <th name="temp" type="f" format="type:num;width:8;dec:1"> Dry Bulb Temp (Celsius)</th> <th name="tflag" type="i" format="type:num;width:4;dec:0"> Dry Bulb Temp Flag</th> <th name="dew" type="f" format="type:num;width:8;dec:1"> Dew Point Temp (Celsius)</th> <th name="hum" type="i" format="type:num;width:5;dec:0"> Relative Humidity (%)</th> <th name="pres" type="i" format="type:num;width:6;dec:0"> Station Pressure (millibars)</th> <th name="pflag" type="i" format="type:num;width:3;dec:0"> Station Pressure Flag</th> <th name="wdir" type="i" format="type:num;width:6;dec:0"> Wind Direction (degrees)</th> <th name="wspd" type="f" format="type:num;width:4;dec:0"> Wind Speed (m/s)</th> <th name="vis" type="f" format="type:num;width:6;dec:1"> Visibility (km)</th> <th name="ceil" type="i" format="type:num;width:6;dec:0"> Ceiling Height (meters)</th> <th name="weath" type="i"> Present Weather</th> <th name="asos1" type="i" format="type:num;width:6;dec:0"> ASOS Cloud Layer 1</th> <th name="asos2" type="i" format="type:num;width:6;dec:0"> ASOS Cloud Layer 2</th> <th name="asos3" type="i" format="type:num;width:6;dec:0"> ASOS Cloud Layer 3</th> <th name="prec" type="i" format="type:num;width:7;dec:0"> Hourly Precip (.01 inch)</th> <th name="rflag" type="a" format="type:char;width:-2"> Hourly Precip Flag</th> <th name="snow" type="i" format="type:num;width:4;dec:0"> Snow Depth (inches)</th> </cols> <data/> </table> </out> puttab (Modify table information) The puttab transaction modifies the meta information for a table. Query String The query string in the HTTP header must contain the following parameters: Connection String Value Variable api puttab apiversion 3 uid [USERNAME] pswd [ENCRYPTED PASSWORD] - returned from the login transaction sid [SESSION ID] (optional) - returned from the login transaction 1010data API Reference Manual | 1010data Application Program Interface | 22 Query String Example api=puttab&apiversion=3&uid=myid&pswd=Aiynnsewxhck&sid=1748453843 XML Input to Server The specifications must contain the following elements: XML Element To Send Description of Sent Element Content <tab> The "table" element of the 1010data xml specification. Information for modifying the table should be included in the attributes of the <tab> element. Descriptions for the attributes are listed in the table below. Include the following attributes with the <tab> element: Note: Any attributes that are omitted will not be modified. XML Element To Send Description of Sent Element Content id The ID of a directory. name The full path of the directory. title The title of the directory as displayed in the UI. sdesc The short description of the directory. ldesc The long description of the directory. secure Is the directory marked as secure. Returns 0 or 1. users Space separated list of users and groups who have permission to view the directory. owner Who is the owner of the directory? Returns the username. gif The GIF file associated with the directory to be displayed in the UI. uploaders Space separated list of users and groups who have permission to create tables or directories inside the directory. XML Input Example <in><tab id="36015" name="pub.demo.weather.newhourly95" title="New Weather Hourly 95" sdesc="" ldesc="" secure="0" /><in> XML Response from Server A successful response from the server contains the following elements: XML Element To Send Description of Sent Element Content <rc> The return code. <msg> The message from the server. 1010data API Reference Manual | 1010data Application Program Interface | 23 XML Element To Send Description of Sent Element Content <tab> New table information. See XML response of gettab (Get information about a table) on page 17. The directory meta data is returned as a series of attributes contained within the <dir> element. The attributes are as follows: XML Response Example A successful puttab produces the following result: <out> <rc>0</rc> <msg>puttab successful</msg> <tab id="173" name="pub.demo.weather.hourly95" type="REAL" display="TABLE" report="0" chart="0" title="Hourly U.S. Weather (1995)" sdesc="Hourly United States weather observations" ldesc="This table contains hourly observations at 262 weather stations over a one year period. Each row contains the data for a particular station at a particular hour of a particular day. Each station is identified by an ID that corresponds to the ID in the Stations table." link="weather" rows="2294858" bytes="266215904" segs="4" tstat="0" access="1" secure="0" maxdown="" own="0" owner="sandy2" update="2007-05-17 08:41:42" favorite="0"/> </out> query (Apply a query to a table) The query transaction applies a query to a table. A query is essentially a transformation on the table that selects a subset of its rows, reorders rows based on one or more sort criteria, summarizes the data and so on. The result is conceptually another table. Once a query is set using the query transaction, the values in the result table may be retrieved with the getdata transaction. Query String The query string in the HTTP header must contain the following parameters: Connection String Value Variable api query apiversion 3 uid [USERNAME] pswd [ENCRYPTED PASSWORD] - returned from the login transaction sid [SESSION ID] (optional) - returned from the login transaction Query String Example api=query&apiversion=3&uid=myid&pswd=Aiynnsewxhck&sid=1748453843 1010data API Reference Manual | 1010data Application Program Interface | 24 XML Input to Server The specifications must contain the following elements: XML Element To Send Description of Sent Element Content <name> The full path to the table in the 1010data database hierarchy. <ops> *optional A series of query operations in the XML macro language used on the Edit Actions page of the 1010data user interface. If <ops> is omitted, the result of the query will be the original table. If <ops> contains one or more <colord> operations, the query transaction takes them into account, i.e. the columns reported in the result (see below) will be only those columns selected in the <colord> operations and they will appear in the order specified in the <colord> operations. XML Input Example <in> <name>pub.demo.weather.hourly95</name> <ops> <sel value="(id=94789)"/> <tabu label="Average temperature and humidity in NYC" breaks="date"> <tcol source="temp" fun="avg" label="Average`Dry Bulb`Temp`(Celsius)"/> <tcol source="hum" fun="avg" label="Average`Relative`Humidity`(%)"/> </tabu> </ops> </in> XML Response from Server A successful response from the server contains the following elements: XML Element To Send Description of Sent Element Content <rc> The return code. <msg> The message from the server. <nrows> Number of rows in result table <table> Information about columns of result table. The<table> element (see Table Tree on page 58) essentially describes the columns of the result. It is equivalent to the result table with zero rows of data (i.e. the <data> element is empty.) The table tree does not contain <title>, <sdesc>, <ldesc>, <link> or <maxdown>. In the event of an error only the return code and error message are returned. XML Response Example A successful query produces the following result: <out> <rc>0</rc> <msg>query successful</msg> <nrows>365</nrows> <table> <cols> <th name="date" type="i" format="type:date"> Date</th> <th name="t0" type="f" format="type:num;width:6;dec:2"> 1010data API Reference Manual | 1010data Application Program Interface | 25 Average Dry Bulb Temp (Celsius)</th> <th name="t1" type="f" format="type:num;width:6;dec:2"> Average Relative Humidity (%)</th> </cols> <data/> </table> </out> getdata (Get the results of a query) The getdata transaction retrieves the results of a query. More precisely, getdata retrieves the values in the result table defined by a query transaction. Query String The query string in the HTTP header must contain the following parameters: Connection String Value Variable api getdata apiversion 3 uid [USERNAME] pswd [ENCRYPTED PASSWORD] - returned from the login transaction sid [SESSION ID] (optional) - returned from the login transaction Query String Example api=getdata&apiversion=3&uid=myid&pswd=Aiynnsewxhck&sid=1748453843 XML Input to Server The specifications must contain the following elements: XML Element To Send Description of Sent Element Content <cols> The column(s) to be retrieved. This element must contain one or more <col> elements. Each identifies one column and contains the name by which the column is referenced in formulas and query operations. <rows> *optional The row(s) to be retrieved. <rows> must include attribute mode which indicates the form of the row specification. mode="1" allows a relative selection (e.g. next 10 rows), while mode="2" allows an absolute selection (e.g. rows 10-20). For mode="1", the <rows> element has the form, <rows mode="1"><next>number of rows</next></rows> while for mode="2", the form is, <rows mode="2"><from>row number</from><to>row number</ to></rows> <next> is required if mode="1" <from> and <to> are required if mode="2". <rows> is optional. If not specified, all rows are retrieved. 1010data API Reference Manual | 1010data Application Program Interface | 26 XML Element To Send Description of Sent Element Content <format> The data format for the result (XML or character separated.) <format> must include attribute type and may include attribute values. type indicates the format type ("xml" or "csv"). If type="xml", the <format> element has no contents. If type="csv", it may contain the following elements: • • <sep> - Character with which to separate columns <linesep> - Character with which to separate rows Both <sep> and <linesep> are optional. If not specified, the column separator is comma and the line separator is newline (" "). Attribute values indicates whether the data values should be "raw" or "formatted". Raw values are a simple representations of the data while formatted values are the way the data appears in a table view in the user interface. Examples of raw values are 1234567, 7.87083333333333, and 19950101, while the corresponding formatted values might be 1,234,567, 7.87, and 1/01/95. If type="csv" and values="formatted", <format> is optional. If not specified, XML data with raw formatting is returned. If <ops> contains one or more <colord> operations, the query transaction takes them into account, i.e. the columns reported in the result (see below) will be only those columns selected in the <colord> operations and they will appear in the order specified in the <colord> operations. XML Input Examples XML Input Example 1: Relative row specification; XML <in> <cols> <col>date</col> <col>t0</col> </cols> <rows mode="1"> <next>3</next> </rows> <format type="xml"/> </in> XML Input Example 2: Absolute row specification; tab-separated; raw values <in> <cols> <col>date</col> <col>t0</col> </cols> <rows mode="2"> <from>1</from> <to>3</to> </rows> <format type="csv"> <sep>	</sep> </format> </in> 1010data API Reference Manual | 1010data Application Program Interface | 27 XML Input Example 3: Absolute row specification; comma-separated; formatted values <in> <cols> <col>date</col> <col>t0</col> </cols> <rows mode="2"> <from>1</from> <to>3</to> </rows> <format type="csv" values="formatted"> <sep>,</sep> </format> </in> XML Response from Server A successful response from the server contains the following elements: XML Element To Send Description of Sent Element Content <rc> The return code. <msg> The message from the server. The <table> element (see Table Tree on page 58) contains the data for the specified columns and rows along with information about each column. (It does not contain <title>, <sdesc>, <ldesc>, <link> or <maxdown>.) Note that the cols element in <table> will differ from the query response if your<format> is set to formatted. Specifically, all the columns will report that they have been converted to alphanumeric which is what happens behind the scenes to properly format the data and is also the correct input if your trying to reload the data via the XML Response Examples The <csv> element contains a CDATA section that contains the data in row-major order. The first row of data contains the column headers. In the event of an error only the return code and error message are returned. Example 1: XML <out> <rc>0</rc> <msg>getdata successful</msg> <table> <cols> <th name="date" type="i" format="type:date"> Date </th> <th name="t0" type="f" format="type:num;width:6;dec:2"> Average Dry Bulb Temp (Celsius) </th> </cols> <data> <tr> <td>19950101</td> <td>7.87083333333333</td> </tr> 1010data API Reference Manual | 1010data Application Program Interface | 28 <tr> <td>19950102</td> <td>2.73333333333333</td> </tr> <tr> <td>19950103</td> <td>-1.6625</td> </tr> </data> </table> </out> Example 2: Tab-separated; raw values <out> <rc>0</rc> <msg>getdata successful</msg> <csv> <![CDATA["Date","Average Dry Bulb Temp (Celsius)" 19950101 → 7.87083333333333 19950102 → 2.73333333333333 19950103 → -1.6625]]> </csv> </out> Example 3: Comma-separated; formatted values <out> <rc>0</rc> <msg>getdata successful</msg> <csv> <![CDATA["Date","Average Dry Bulb Temp (Celsius)" 19950101 → 7.87083333333333 19950102 → 2.73333333333333 19950103 → -1.6625]]> </csv> </out> In the last example, the → represents a TAB character. querydata (Apply a query to a table and get results) The querydata transaction applies a query to a table and gets the results as if you called a query and a single getdata transaction. querydata takes the union of parameters from query and getdata respectively and returns the union of results from both query and getdata. querydata is convenient and useful when you know the resulting dataset will be smaller than your maximum allowed download from a single transaction. Otherwise, you will still have to subsequently call getdata to receive all of the results. 1010data API Reference Manual | 1010data Application Program Interface | 29 Query String The query string in the HTTP header must contain the following parameters: Connection String Value Variable api querydata apiversion 3 uid [USERNAME] pswd [ENCRYPTED PASSWORD] - returned from the login transaction sid [SESSION ID] (optional) - returned from the login transaction Query String Example api=querydata&apiversion=3&uid=myid&pswd=Aiynnsewxhck&sid=1748453843 XML Input to Server The specifications must contain the following elements: See XML input to query (query (Apply a query to a table) on page 23) and getdata (getdata (Get the results of a query) on page 25), as the querydata transaction requires the input of both query and getdata. XML Response from Server A successful querydata contains the following elements: XML Element Returned Description of Returned Element Content <rc> Return code <msg> Message from the system <nrows> Number of rows in result table <table> Information about columns of result table and the resulting data savefile (Save query results as a file) The savefile transaction saves the results of a query as a file in your 1010data FTP folder. The file can then be downloaded via FTP. Note: To use this transaction, you must be authorized for FTP downloads. Query String The query string in the HTTP header must contain the following parameters: Connection String Value Variable api savefile 1010data API Reference Manual | 1010data Application Program Interface | 30 Connection String Value Variable apiversion 3 uid [USERNAME] pswd [ENCRYPTED PASSWORD] - returned from the login transaction sid [SESSION ID] (optional) - returned from the login transaction Query String Example api=savefile&apiversion=3&uid=myid&pswd=Aiynnsewxhck&sid=1748453843 XML Input to Server The specifications must contain the following elements: XML Element To Send Description of Sent Element Content <file> The name of the result file. If a file already exists with that name, it will be replaced. <content> The meta information to include in the file. <content> must contain one or more <meta> elements, each identifying one type of information. Each <meta> element must include attribute type and type may have one of the following values: • • headers - Column headers names - Column names <content> is optional. If not specified, no meta information is included in the file. <format> The data format for the result. <format> has no attributes and may contain the following elements: • • <sep> - Character with which to separate fields (columns) <linesep> - Character with which to separate records (rows) If not specified, the column separator is a comma,and the line separator is newline ( ). <file> is required; the others are optional. XML Input Example <in> <file>My File</file> <content> <meta type="names"/> </content> <format> <sep>,</sep> </format> </in> XML Response from Server A successful savefile contains the following elements: 1010data API Reference Manual | 1010data Application Program Interface | 31 XML Element Returned Description of Returned Element Content <rc> Return code <msg> Message from the system XML Response Example <out> <rc>0</rc> <msg>Saved file My File</msg> </out> savetable (Save query results as a table) The savetable transaction saves the results of a query as a new table. The table is added to the 1010data database hierarchy and may be made accessible to other users. Query String The query string in the HTTP header must contain the following parameters: Connection String Value Variable api savetable apiversion 3 uid [USERNAME] pswd [ENCRYPTED PASSWORD] - returned from the login transaction sid [SESSION ID] (optional) - returned from the login transaction Query String Example api=savetable&apiversion=3&uid=myid&pswd=Aiynnsewxhck&sid=1748453843 XML Input to Server The specifications must contain the following elements: XML Element To Send Description of Sent Element Content <name> The contents of this element is the full path for the new table in the 1010data database hierarchy. <name> may include optional attribute mode. If a table already exists by this name and mode="replace", the table will be replaced. If mode="noreplace", an error message will be returned. If you want to append the data to the end of an existing table, specifying mode="append” will insert the records from the results for those columns whose names and types are compatible with the table specified in <name>. If mode is omitted, the default is noreplace. <title> The title for the new table (see <title> (Table title) on page 64). 1010data API Reference Manual | 1010data Application Program Interface | 32 XML Element To Send Description of Sent Element Content <sdesc> The short description for the new table (see <sdesc> (Short description of a table) on page 59). <ldesc> The long description for the new table (see <ldesc> (Long description of a table) on page 59). <link> The link header for the new table (see <link> (Link header) on page 60). <maxdown> The download limit for the new table (see <maxdown> (Download limit) on page 61). <merge> A flag indicating whether the table should be able to be merged with other tables. If you plan to merge the saved table with another table that you save or upload, specify <merge>1</merge>. However, your queries will run faster and use less virtual memory if you specify <merge>0</merge> or omit the <merge> element entirely. <users> The access rights for the new table (see Users Tree on page 66). <modcol> Modify a column by changing its name, title, and/or display format. Specify the column you wish to modify with the required name attribute and optionally specify title to change the title and format to change the display format (See <th> (Meta information for one column) on page 63.) Also, a new name can be provided as the value of <modcol> XML element. See the example below for more clarity. <name> is required; the others are optional. XML Input Example <in> <name mode="noreplace">myfolder.mytable</name> <title>My Table</title> <users> <user>john</user> <user>tom</user> </users> <modcol name="year" title="New Title" format="type:nocommas;width:4">new_year</modcol> </in> <user>tom</user> </users> </in> XML Response from Server A successful savetable contains the following elements: XML Element Returned Description of Returned Element Content <rc> Return code <msg> Message from the system XML Response Example <out> 1010data API Reference Manual | 1010data Application Program Interface | 33 <rc>0</rc> <msg>Saved table myfolder.mytable</msg> </out> upload (Upload table) The upload transaction uploads a table from the client machine to the 1010data database servers. The table is added to the 1010data database hierarchy and may be made accessible to other users. There is a 5 MB limit on the size of the input for this transaction. For large tables, its recommended to use the PowerLoader API. Query String The query string in the HTTP header must contain the following parameters: Connection String Value Variable api upload apiversion 3 uid [USERNAME] pswd [ENCRYPTED PASSWORD] - returned from the login transaction sid [SESSION ID] (optional) - returned from the login transaction Query String Example api=upload&apiversion=3&uid=myid&pswd=Aiynnsewxhck&sid=1748453843 XML Input to Server The specifications must contain the following elements: XML Element To Send Description of Sent Element Content <table> The table information in the form of a table tree (see Table Tree on page 58). The name attribute of the <table> element optionally specifies the desired location of the table in the 1010data database hierarchy (see also <name> below). The parent directory must exist and the user must be authorized to add tables to it. <title>, <sdesc>, <ldesc>, <link>, and <maxdown> are all optional. <name> This element is ignored if the name attribute of the <table> element is specified. If the name attribute of the <table> element is omitted, the contents of this element specifies the full path for the new table in the 1010data database hierarchy. <name> may include optional attribute mode. If a table already exists by this name and mode="replace", the table will be replaced. If mode="noreplace", an error message will be returned. If you want to append the data to the end of an existing table, specifying mode="append” will insert the records from the results for those columns whose names and types are compatible with the table specified in <name>. If mode is omitted, the default is noreplace. <merge> A flag indicating whether the table should be able to be merged with other tables. 1010data API Reference Manual | 1010data Application Program Interface | 34 XML Element To Send Description of Sent Element Content If you plan to merge the uploaded table with another table that you upload or save, specify <merge>1</merge>. However, your queries will run faster and use less virtual memory if you specify <merge>0</merge> or omit the <merge> element entirely. <users> The access rights for the new table (see Users Tree on page 66). <table> is required; <name> and <users> are optional. If <users> is omitted,only the uploading user will have access to the table. XML Input Example <in> <table> <title>My Table</title> <cols> <th name="name" type="a">Full Name</th> <th name="age" type="i" format="type:nocommas;width:2">Age</th> </cols> <data> <tr> <td>John Doe</td> <td>31</td> </tr> <tr> <td>Mary Doe</td> <td>29</td> </tr> <tr> <td>Robert Smith</td> <td>45</td> </tr> </data> </table> <name mode="noreplace">myfolder.mytable</name> <users> <user>john</user> <user>tom</user> </users> </in> XML Response from Server A successful upload contains the following elements: XML Element Returned Description of Returned Element Content <rc> Return code <msg> Message from the system XML Response Example <out> <rc>0</rc> <msg>Added table myfolder.mytable</msg> </out> 1010data API Reference Manual | 1010data Application Program Interface | 35 merge (Merge table) The merge transaction creates a new table by combining one or more existing tables. The table is added to the 1010data database hierarchy and may be made accessible to other users. The tables are combined by appending all their rows together (i.e., the new table has similar columns to the original tables but has as many rows as the sum of the rows of the original tables). The original tables must have some columns in common, and each of those columns must have the same data type and other attributes (NA values, alphabetic case, etc.) in all the tables. If some columns do not appear in all the tables, those columns are not included in the new table. Query String The query string in the HTTP header must contain the following parameters: Connection String Value Variable api merge apiversion 3 uid [USERNAME] pswd [ENCRYPTED PASSWORD] - returned from the login transaction sid [SESSION ID] (optional) - returned from the login transaction Query String Example api=merge&apiversion=3&uid=myid&pswd=Aiynnsewxhck&sid=1748453843 XML Input to Server The specifications must contain the following elements: XML Element To Send Description of Sent Element Content <tabs> The table(s) to be combined. <tabs> must contain one or more <tab> elements. Each identifies one table and contains its full path in the 1010data database hierarchy. <name> The contents of this element is the full path for the new table in the 1010data database hierarchy. The parent directory must exist and the user must be authorized to add tables to it. <name> may include optional attribute mode. If a table already exists by this name and mode="replace", the table will be replaced. If mode="noreplace", an error message will be returned. If mode is omitted, the default is noreplace. <title> The title for the new table (see <title> (Table title) on page 64). <sdesc> The short description for the new table (see <sdesc> (Short description of a table) on page 59). <ldesc> The long description for the new table (see <ldesc> (Long description of a table) on page 59). 1010data API Reference Manual | 1010data Application Program Interface | 36 XML Element To Send Description of Sent Element Content <link> The link header for the new table (see <link> (Link header) on page 60). <maxdown> The download limit for the new table (see <maxdown> (Download limit) on page 61). <users> The access rights for the new table (see Users Tree on page 66). <tabs> and <name> are required; the others are optional. XML Input Example <in> <tabs> <tab>annualtables.t2001</tab> <tab>annualtables.t2002</tab> </tabs> <name mode="noreplace">myfolder.mytable</name> <title>2001-2002</title> <users> <user>john</user> <user>tom</user> </users> </in> XML Response from Server A successful merge contains the following elements: XML Element Returned Description of Returned Element Content <rc> Return code <msg> Message from the system XML Response Example <out> <rc>0</rc> <msg>Saved table myfolder.mytable</msg> </out> droptable (Delete table) The droptable transaction deletes a table from the 1010data database servers. All information about the table, including all of its data, is lost. The user must be authorized to delete the table. Query String The query string in the HTTP header must contain the following parameters: Connection String Value Variable api droptable apiversion 3 1010data API Reference Manual | 1010data Application Program Interface | 37 Connection String Value Variable uid [USERNAME] pswd [ENCRYPTED PASSWORD] - returned from the login transaction sid [SESSION ID] (optional) - returned from the login transaction Query String Example api=droptable&apiversion=3&uid=myid&pswd=Aiynnsewxhck&sid=1748453843 XML Input to Server The specifications must contain the following elements: XML Element To Send Description of Sent Element Content <name> The full path to the table in the 1010data database hierarchy. XML Input Example <in><name>myfolder.mytable</name></in> XML Response from Server A successful droptable contains the following elements: XML Element Returned Description of Returned Element Content <rc> Return code <msg> Message from the system XML Response Example <out> <rc>0</rc> <msg>Table myfolder.mytable deleted</msg> </out> dropdir (Delete directory) The dropdir transaction deletes a directory from the 1010data database servers. All information about the folder, including all of its data, is lost. The user must be authorized to delete the directory. Query String The query string in the HTTP header must contain the following parameters: Connection String Value Variable api dropdir apiversion 3 1010data API Reference Manual | 1010data Application Program Interface | 38 Connection String Value Variable uid [USERNAME] pswd [ENCRYPTED PASSWORD] - returned from the login transaction sid [SESSION ID] (optional) - returned from the login transaction Query String Example api=dropdir&apiversion=3&uid=myid&pswd=Aiynnsewxhck&sid=1748453843 XML Input to Server The specifications must contain the following elements: XML Element To Send Description of Sent Element Content <name> The full path to the directory in the 1010data database hierarchy. XML Input Example <in><name>myfolder.myfolder</name></in> XML Response from Server A successful dropdir contains the following elements: XML Element Returned Description of Returned Element Content <rc> Return code <msg> Message from the system XML Response Example <out> <rc>0</rc> <msg>Directory myfolder.myfolder deleted</msg> </out> drop (Delete several tables or folders) The drop transaction deletes any number of tables and directories from the 1010data database servers. All information about the table, including all of its data, is lost. The user must be authorized to delete the items. Query String The query string in the HTTP header must contain the following parameters: Connection String Value Variable api drop 1010data API Reference Manual | 1010data Application Program Interface | 39 Connection String Value Variable apiversion 3 uid [USERNAME] pswd [ENCRYPTED PASSWORD] - returned from the login transaction sid [SESSION ID] (optional) - returned from the login transaction Query String Example api=drop&apiversion=3&uid=myid&pswd=Aiynnsewxhck&sid=1748453843 XML Input to Server The specifications must contain the following elements: XML Element To Send Description of Sent Element Content <objects> A list of <names> to be deleted. <names> can contain paths or IDs. XML Input Example <in> <objects> <name>pub.demo.weather.hourly95</name> <name>pub.demo.baseball</name> </objects> <in> XML Response from Server A successful drop contains the following elements: XML Element Returned Description of Returned Element Content <rc> Return code If <rc> is nonzero, it means one or more of the drops did not work. <msg> Message from the system <statuses> The result codes and messages for each of the items dropped Statuses contains a list of <status> elements with a name attribute and the following elements: XML Element Returned Description of Returned Element Content <rc> Return code <msg> Message from the system XML Response Example <out> <rc>0</rc> <msg>Drop Successful</msg> <statuses> 1010data API Reference Manual | 1010data Application Program Interface | 40 <status name=“pub.demo.weather.hourly95\"><rc>0</rc><msg>Drop Successful for pub.demo.weather.hourly95</msg></status> <status name=“pub.demo.baseball\"><rc>0</rc><msg>Drop Successful for pub.demo.baseball</msg></status> </statuses> </out> move (Move several tables or folders) The move transaction moves any number of tables from anywhere in the folder hierarchy to a single directory. Query String The query string in the HTTP header must contain the following parameters: Connection String Value Variable api move apiversion 3 uid [USERNAME] pswd [ENCRYPTED PASSWORD] - returned from the login transaction sid [SESSION ID] (optional) - returned from the login transaction Query String Example api=move&apiversion=3&uid=myid&pswd=Aiynnsewxhck&sid=1748453843 XML Input to Server The specifications must contain the following elements: XML Element To Send Description of Sent Element Content <source> A list of <names> to be moved. <names> can contain paths or IDs. XML Input Example <in> <source> <name>pub.demo.weather.baseball95</name> <name>pub.demo.weather.baseball97</name> </source> <target>pub.demo.baseball</target> <in> XML Response from Server A successful move contains the following elements: XML Element Returned Description of Returned Element Content <rc> Return code 1010data API Reference Manual | 1010data Application Program Interface | 41 XML Element Returned Description of Returned Element Content If <rc> is nonzero, it means one or more of the moves did not work. <msg> Message from the system <statuses> The result codes and messages for each of the items moved Statuses contains a list of <status> elements with a name attribute and the following elements: XML Element Returned Description of Returned Element Content <rc> Return code <msg> Message from the system XML Response Example <out> <rc>0</rc> <msg>Move Successful</msg> <statuses> <status name="pub.demo.weather.baseball95"><rc>0</rc><msg>Move Successful for pub.demo.weather.baseball95</msg></status> <status name="pub.demo.weather.baseball97"><rc>0</rc><msg>Move Successful for pub.demo.weather.baseball97</msg></status> </statuses> </out> order (Order the items in a directory) The order transaction orders the items in a directory. Note that directories and tables can not be interspersed with one another. Query String The query string in the HTTP header must contain the following parameters: Connection String Value Variable api order apiversion 3 uid [USERNAME] pswd [ENCRYPTED PASSWORD] - returned from the login transaction sid [SESSION ID] (optional) - returned from the login transaction Query String Example api=order&apiversion=3&uid=myid&pswd=Aiynnsewxhck&sid=1748453843 XML Input to Server The specifications must contain the following elements: 1010data API Reference Manual | 1010data Application Program Interface | 42 XML Element To Send Description of Sent Element Content <name> The full path to the directory in the 1010data database hierarchy where you want to reorder items. <dirs> A list of <name> elements of the directories in the folder where the order of the <names> represents the order desired in 1010data. <tabs> A list of <name> elements of the tables in the folder where the order of the <names> represents the order desired in 1010data. XML Input Example <in> <name>myfolder.myfolder</name> <dirs> <name>myfolder.myfolder1</name> <name>myfolder.myfolder2</name> </dirs> <tabs> <name>myfolder.mytable1</name> <name>myfolder.mytable2</name> </tabs> </in> XML Response from Server A successful order contains the following elements: XML Element Returned Description of Returned Element Content <rc> Return code <msg> Message from the system XML Response Example <out> <rc>0</rc> <msg>Order Successful</msg> </out> clear (Clear the cache) Once the results of a query are retrieved or saved, it often makes sense to free up virtual memory before running another query. The clear transaction clears some or all of the memory used by the first query. Be careful: Do not use the clear transaction until you are finished saving or retrieving the results of the first query. If you do, the system will have to recompute the results from scratch. Query String The query string in the HTTP header must contain the following parameters: Connection String Value Variable api clear 1010data API Reference Manual | 1010data Application Program Interface | 43 Connection String Value Variable apiversion 3 uid [USERNAME] pswd [ENCRYPTED PASSWORD] - returned from the login transaction sid [SESSION ID] (optional) - returned from the login transaction Query String Example api=clear&apiversion=3&uid=myid&pswd=Aiynnsewxhck&sid=1748453843 XML Input to Server None. XML Response from Server A successful clear contains the following elements: XML Element Returned Description of Returned Element Content <rc> Return code <msg> Message from the system XML Response Example <out> <rc>0</rc> <msg>Cache cleared</msg> </out> refresh (Refresh) The refresh transaction will apply database updates to your session. The transaction invalidates and clears cache. Query String The query string in the HTTP header must contain the following parameters: Connection String Value Variable api refresh apiversion 3 uid [USERNAME] pswd [ENCRYPTED PASSWORD] - returned from the login transaction sid [SESSION ID] (optional) - returned from the login transaction 1010data API Reference Manual | 1010data Application Program Interface | 44 Query String Example api=refresh&apiversion=3&uid=myid&pswd=Aiynnsewxhck&sid=1748453843 XML Input to Server The specifications must contain the following elements: XML Element To Send Description of Sent Element Content <name> The full path to the table in the 1010data database hierarchy. XML Input Example <in><name>myfolder.mytable</name></in> XML Response from Server A successful refresh contains the following elements: XML Element Returned Description of Returned Element Content <rc> Return code <msg> Message from the system XML Response Example <out> <rc>0</rc> <msg>Refresh Successful</msg> </out> session (Set session parameters) Under certain circumstances it may be useful to adjust how queries use system resources such as processing power and virtual memory. The session transaction provides a means to effect such changes. Query String The query string in the HTTP header must contain the following parameters: Connection String Value Variable api session apiversion 3 uid [USERNAME] pswd [ENCRYPTED PASSWORD] - returned from the login transaction sid [SESSION ID] (optional) - returned from the login transaction Query String Example api=session&apiversion=3&uid=myid&pswd=Aiynnsewxhck&sid=1748453843 1010data API Reference Manual | 1010data Application Program Interface | 45 XML Input to Server The specifications must contain the following elements: XML Element To Send Description of Sent Element Content <inf2na> Some computations (e.g., dividing by zero) can result in errors or "infinity" values (0I, -0I, 0i, or -0i). Setting this parameter to on can help reduce or eliminate this behavior. Specifically: • Division by zero (X/0) returns 0i or -0i if the numerator is not zero. • Checking this box causes N/A to be returned instead of 0i and -0i. Exponentiation (X^Y) can generate error messages if X is negative. • Checking this box mostly eliminates such messages and causes N/A to be returned in the event of an error. The range functions (range1, range1f, etc.) return 0I, -0I, 0i, or -0i for column values that lie outside the specified ranges. Valid values are on and off. <stepwise> Setting this parameter to on saves memory but may cause queries to run more slowly. Choose this setting only if you experience virtual memory problems when working with large tables. Valid values are on and off. <blocking> Setting this parameter to lower numbers saves memory but may cause queries to run more slowly. Use lower numbers when doing row selections and tabulations on large tables if you experience virtual memory problems. Valid values are the integers 0 through 10. All elements are optional. XML Input Example <in> <inf2na>on</inf2na> <blocking>0</blocking> </in> XML Response from Server A successful session contains the following elements: XML Element Returned Description of Returned Element Content <rc> Return code <msg> Message from the system XML Response Example <out> 1010data API Reference Manual | 1010data Application Program Interface | 46 <rc>0</rc> <msg>Session parameters set</msg> </out> 1010data API Reference Manual | PowerLoader Transactions | 47 PowerLoader Transactions This section provides a series of interactions for managing PowerLoader API sessions. addtab (Load a large table) The addtab transaction loads a large table into the 1010data system. The transaction expects source data in your FTP account, so ensure the data is fully uploaded via FTP before invoking this transaction. As input, addtab accepts an XML version of the 1010 PowerLoader V1 spec file. If you still wish to use the legacy format, use the convert transaction to convert your PowerLoader V1 spec file into an XML spec. This transaction can be invoked synchronously or asynchronously or with the <sync> tag. In sync mode, the transaction returns when the table is finished loading. In async mode, when the transaction returns a response, it does not mean the table is created, it means table creation has successfully been initiated. With async mode, you use the status transaction to check on the status of the table creation. Sync mode is recommended for small tables (<1 million records) and async mode is recommended for large tables (> 1 million records). Note: To use this transaction, you must have a 1010data FTP account. Query String The query string in the HTTP header must contain the following parameters: Connection String Value Variable api addtab apiversion 3 uid [USERNAME] pswd [ENCRYPTED PASSWORD] - returned from the login transaction sid [SESSION ID] (optional) - returned from the login transaction Query String Example api=addtab&apiversion=3&uid=myid&pswd=Aiynnsewxhck&sid=1748453843 XML Input to Server The specifications must contain the following elements: XML Element To Send Description of Sent Element Content <sync></sync> 1 if you want to load synchronously, or 0 if you want the table to load asynchronously. <spec> Outer specification element (required) <source> List of source files (required) <file></file> File element <name></name> File path of table in 1010data (e.g., mycompany.mytable). 1010data API Reference Manual | PowerLoader Transactions | 48 XML Element To Send Description of Sent Element Content If you reference an existing table, addtab will replace it. <title></title> Title as it appears in the user interface <sdesc></sdesc> Short description of the table <ldesc></ldesc> Long description of table <link></link> Link header <users type="[TYPE]"></ users> Specifies users provisioned for table access. If the <users> element is excluded, only the table owner may access the table. See Users Tree on page 66 for XML schema and <users> (Top-level wrapper for users tree) on page 66 for usage details. <user></user> Specifies each user that may access the table. Used in conjunction with the <users> element when type is list (or if type is omitted). Each <user> element is nested inside the <users> top-level wrapper. <rectype></rectype> fixed or separated (required) <sep></sep> Single character delimiter. Required if rectype is separated. <eor></eor> End of record delimiter <arch></arch> Byte order of data - little or big endian <begbytes></begbytes> Number of bytes to skip at the beginning of e/file <begrecs></begrecs> Number of records to skip in the beginning of e/file <numrecs></numrecs> Number of records to load in e/file <ts></ts> Time-series flag. 1 for true, or 0 for false. Requires that <bord> tags are provided in at least one column. <cols> Column specifications (required) List of <col> elements, one for each column in the file. <col> A column element (required) There must be one of these for each column in the table. <name></name> Field name (required) Must begin with an alphabetical character. <width></width> Field width in the raw file (required) (Optional if rectype is separated.) <help></help> Column help (text inside ? marker above column) <skip></skip> Field is read but not displayed in table 1010data API Reference Manual | PowerLoader Transactions | 49 XML Element To Send Description of Sent Element Content <type></type> Field data type (required) See Field Data Types on page 68. <scale></scale> Divisor used to divide raw value. <case></case> Force case, either upper or lower <nowrite></nowrite> Ignore the field; don’t include it in the table. <order></order> Column placement relative to other columns (integer) <fix></fix> Column is non-scrolling (pink) <head></head> Column header Use ` to separate lines. <exp></exp> 1010 expression applied to raw data (not nested) <format></format> Formatting Spec Must specify <type></type>, <width></width>, and <dec></dec> See Field Format Types on page 69. <bord></bord> TS segmentation order (integer). The number provided here is the relative segmentation order of this column in relation to other columns with the <bord> tag. Think of <bord> columns as tabulation breaks. The column that denotes time should have the largest number in the sequence. XML Input Example <in> <spec> <source> <file>mytable20060101.txt</file> <file>mytable20060201.txt</file> </source> <name>mycompany.mytable</name> <title>Mytable 2006</title> <sdesc>short description of the table</sdesc> <ldesc>long description of table</ldesc> <link>FOO</link> <users> <user>user1</user> <user>user2</user> </users> <rectype>fixed</rectype> <eor>crlf</eor> <cols> <col> <field>deal</field> <width>12</width> <head>Deal ID</head> <type>int</type> <format> <type>nocommas</type> <width>3</width> <dec>0</dec> 1010data API Reference Manual | PowerLoader Transactions | 50 </format> </col> <col> <field>date</field> <width>55</width> <head>Distributaion Date</head> <type>yyyymmdd</type> <format> <type>date</type> <width>8</width> </format> </col> <col> <field>loan</field> <width>21</width> <head>Loan`Number</head> <type>int</type> <exp>loan+2</exp> </col> </cols> </spec> </in> XML Response from Server A successful addtab produces the following result: <rc>0</rc> <msg>addtab successful</msg> <name>mycompany.mytable</name> status (Status of the addtab API) The status transaction reports the status of an addtab transaction. The return code indicates the state of the load process. Query String The query string in the HTTP header must contain the following parameters: Connection String Value Variable api status apiversion 3 uid [USERNAME] pswd [ENCRYPTED PASSWORD] - returned from the login transaction sid [SESSION ID] (optional) - returned from the login transaction Query String Example api=status&apiversion=3&uid=myid&pswd=Aiynnsewxhck&sid=1748453843 XML Input to Server None. 1010data API Reference Manual | PowerLoader Transactions | 51 XML Response from Server A successful status produces the following result: XML Element Received Description of Element Content <rc> (required) Return code <message> (required) The message sent by the system <numrecs> Number of records written to the table so far. Reported if addtab is in the Loading state. <totrecs> Estimate of the number of records in the source file. Possible Return Codes • • • • • • 0 - Idle – Server is idle and has not started loading anything. 1 - Failed – Server could not load file. 2 - Initializing – Server is validating load specification. Loading has not commenced. 3 - Loading – Server is in the process of loading a table. More tables cannot be loaded until it is complete. 4 - Completed – Server has completed an loading the table. 5 - Diagnosed – The server loaded the table but there were file format issues. The server attempted to automatically correct the issues. XML Response Example <rc>4</rc> <msg>Completed</msg> convert (Convert a legacy spec) The convert transaction will parse and convert a legacy PowerLoader spec file into XML. Note: The user must have a FTP account with a spec file in the top level directory. Query String The query string in the HTTP header must contain the following parameters: Connection String Value Variable api convert apiversion 3 uid [USERNAME] pswd [ENCRYPTED PASSWORD] - returned from the login transaction sid [SESSION ID] (optional) - returned from the login transaction Query String Example api=convert&apiversion=3&uid=myid&pswd=Aiynnsewxhck&sid=1748453843 1010data API Reference Manual | PowerLoader Transactions | 52 XML Input to Server The specifications must contain the following elements: XML Element To Send Description of Sent Element Content <name></name> The spec filename to convert located on your FTP account. See PowerLoader User's Guide for file format. XML Response from Server A successful convert produces the following result: XML Element Returned Description of Returned Element Content <rc> Return code <msg> Message from the system <spec> XML Spec file – See addtab (Load a large table) on page 47 for transaction XML Input. XML Response Example <rc>0</rc> <msg>validate successful</msg> <spec> <source> <file>performance2001-2005.txt</file> <file>performance2006.txt</file> </source> <name>pub.demos.foo.performance</name> <title>Performance 2001-2006</title> <sdesc>short description of the table</sdesc> <ldesc>long description of table</ldesc> <link>FOO</link> <users> <user>user1</user> <user>user2</user> </users> <rectype>fixed</rectype> <eor>crlf</eor> <cols> <col> <field>deal</field> <width>12</width> <head>Deal ID</head> <type>int</type> <format> <type>nocommas</type> <width>3</width> <dec>0</dec> </format> </col> <col> <field>date</field> <width>55</width> <head>Distributaion Date</head> <type>yyyymmdd</type> <format> <type>date</type> 1010data API Reference Manual | PowerLoader Transactions | 53 <width>8</width> </format> </col> <col> <field>loan</field> <width>21</width> <head>Loan`Number</head> <type>int</type> <exp>loan+2</exp> </col> </cols> </spec> edittab (Edit a table) The edittab transaction changes the table Meta data (table information acquired via tabinfo). Query String The query string in the HTTP header must contain the following parameters: Connection String Value Variable api edittab apiversion 3 uid [USERNAME] pswd [ENCRYPTED PASSWORD] - returned from the login transaction sid [SESSION ID] (optional) - returned from the login transaction Query String Example api=edittab&apiversion=3&uid=myid&pswd=Aiynnsewxhck&sid=1748453843 XML Input to Server The specifications consist of the table element from the XML response of tabinfo. The difference is that one can opt to only transmit the top level elements being updated. See tabinfo (Get information about a table) on page 19 for detailed info about the response specification. The following element is required: <table name=”path.to.table”> The table element is required and must contain at least one of the following. See tabinfo XML output for a detailed schema. XML Element To Send Description of Sent Element Content <title> Table title <secure> Secure SSL access <owner> Table owner <ldesc> Long description of the table <link> Link header <cols> Column information 1010data API Reference Manual | PowerLoader Transactions | 54 XML Input Example <in> <table name=”mycompany.mytable”> <title>Mytable’s new Title</title> </table> </in> XML Response from Server A successful result contains the following elements: XML Element Returned Description of Returned Element Content <rc> Return code <msg> Message XML Response Example <rc>0</rc> <msg>edittab successful</msg> validate (Validate a table) The validate transaction will parse and validate the XML spec input to addtab. Query String The query string in the HTTP header must contain the following parameters: Connection String Value Variable api validate apiversion 3 uid [USERNAME] pswd [ENCRYPTED PASSWORD] - returned from the login transaction sid [SESSION ID] (optional) - returned from the login transaction Query String Example api=validate&apiversion=3&uid=myid&pswd=Aiynnsewxhck&sid=1748453843 XML Input to Server The specifications must contain the following elements: XML Element To Send Description of Sent Element Content <sync></sync> 1 if you want to load synchronously, or 0 if you want the table to load asynchronously. <spec> Outer specification element (required) <source> List of source files (required) 1010data API Reference Manual | PowerLoader Transactions | 55 XML Element To Send Description of Sent Element Content <file></file> File element <name></name> File path of table in 1010data (e.g., mycompany.mytable). If you reference an existing table, addtab will replace it. <title></title> Title as it appears in the user interface <sdesc></sdesc> Short description of the table <ldesc></ldesc> Long description of table <link></link> Link header <users type="[TYPE]"></ users> Specifies users provisioned for table access. If the <users> element is excluded, only the table owner may access the table. See Users Tree on page 66 for XML schema and <users> (Top-level wrapper for users tree) on page 66 for usage details. <user></user> Specifies each user that may access the table. Used in conjunction with the <users> element when type is list (or if type is omitted). Each <user> element is nested inside the <users> top-level wrapper. <rectype></rectype> fixed or separated (required) <sep></sep> Single character delimiter. Required if rectype is separated. <eor></eor> End of record delimiter <arch></arch> Byte order of data - little or big endian <begbytes></begbytes> Number of bytes to skip at the beginning of e/file <begrecs></begrecs> Number of records to skip in the beginning of e/file <numrecs></numrecs> Number of records to load in e/file <ts></ts> Time-series flag. 1 for true, or 0 for false. Requires that <bord> tags are provided in at least one column. <cols> Column specifications (required) List of <col> elements, one for each column in the file. <col> A column element (required) There must be one of these for each column in the table. <name></name> Field name (required) Must begin with an alphabetical character. <width></width> Field width in the raw file (required) (Optional if rectype is separated.) 1010data API Reference Manual | PowerLoader Transactions | 56 XML Element To Send Description of Sent Element Content <help></help> Column help (text inside ? marker above column) <skip></skip> Field is read but not displayed in table <type></type> Field data type (required) See Field Data Types on page 68. <scale></scale> Divisor used to divide raw value. <case></case> Force case, either upper or lower <nowrite></nowrite> Ignore the field; don’t include it in the table. <order></order> Column placement relative to other columns (integer) <fix></fix> Column is non-scrolling (pink) <head></head> Column header Use ` to separate lines. <exp></exp> 1010 expression applied to raw data (not nested) <format></format> Formatting Spec Must specify <type></type>, <width></width>, and <dec></dec> See Field Format Types on page 69. <bord></bord> TS segmentation order (integer). The number provided here is the relative segmentation order of this column in relation to other columns with the <bord> tag. Think of <bord> columns as tabulation breaks. The column that denotes time should have the largest number in the sequence. XML Input Example <in> <spec> <source> <file>mytable20060101.txt</file> <file>mytable20060201.txt</file> </source> <name>mycompany.mytable</name> <title>Mytable 2006</title> <sdesc>short description of the table</sdesc> <ldesc>long description of table</ldesc> <link>FOO</link> <users> <user>user1</user> <user>user2</user> </users> <rectype>fixed</rectype> <eor>crlf</eor> <cols> <col> <field>deal</field> <width>12</width> <head>Deal ID</head> <type>int</type> <format> 1010data API Reference Manual | PowerLoader Transactions | 57 <type>nocommas</type> <width>3</width> <dec>0</dec> </format> </col> <col> <field>date</field> <width>55</width> <head>Distributaion Date</head> <type>yyyymmdd</type> <format> <type>date</type> <width>8</width> </format> </col> <col> <field>loan</field> <width>21</width> <head>Loan`Number</head> <type>int</type> <exp>loan+2</exp> </col> </cols> </spec> </in> XML Response from Server A successful validate produces the following result: XML Element Returned Description of Returned Element Content <rc> Return code <msg> Message from the system XML Response Example <rc>0</rc> <msg>validate successful</msg> 1010data API Reference Manual | Table Tree | 58 Table Tree The table tree is a generic way of representing a table in XML and is used in transmitting table data or other tabular information to and from the server. The overall format is as follows: <table name="table name"> <title>table title</title> <sdesc>short description</sdesc> <ldesc>long description</ldesc> <link>link header</link> <maxdown>download limit</maxdown> <cols> <th name="name of first column" type="data type of first column" format="data format of first column"> heading of first column </th> <th name="name of second column" type="data type of second column" format="data format of second column"> heading of second column </th> # <th name="name of last column" type="data type of last column" format="data format of last column"> heading of last column </th> </cols> <data> <tr> <td>value of first row of first column</td> <td>value of first row of second column</td> # <td>value of first row of last column</td> </tr> <tr> <td>value of second row of first column</td> <td>value of second row of second column</td> # <td>value of second row of last column</td> </tr> # <tr> <td>value of last row of first column</td> <td>value of last row of second column</td> # <td>value of last row of last column</td> </tr> </data> </table> The component elements are described in detail in this section. Not all components are used in all transactions. See the description of a transaction for information as to which components are relevant to that transaction. <cols> (Metadata for all columns) Returns the metadata for all columns in a table. 1010data API Reference Manual | Table Tree | 59 Attributes None Contents <cols> is a wrapper for column meta information and must contain one <th> element for each column in the table (see <th> (Meta information for one column) on page 63). <data> (Table data) Returns the data in a table. Attributes None Contents <data> is a wrapper for the table data and must contain one <tr> element for each row of the table (see <tr> (Data for one row) on page 65). <sdesc> (Short description of a table) Returns the short description of a table from the table metadata. Attributes None Contents The short description of the table (i.e., the text that appears in the Short Description field in the 1010data web interface). <ldesc> (Long description of a table) Returns the long description of a table from the table metadata. Attributes None Contents The long description of the table (i.e., the text that appears when the user clicks on the table in the 1010data file viewer and then clicks View Info to see information about the table). For example, in the screenshot below, the text that appears under the heading Long Description. 1010data API Reference Manual | Table Tree | 60 <link> (Link header) Returns the link header of a table. The link header is used to indicate which columns have come from a foreign table after it has been linked to another table. Attributes None Contents A short (one or two word) title that is used when the table is linked to another table. In a link, this title is prepended to the heading of each column from this table to distinguish them from columns from the other table. For example, in the screenshot below, the Product Master table was linked to the Sales Item Detail table. The headings of the columns from the Product Master table therefore begin with "Link Header". 1010data API Reference Manual | Table Tree | 61 <links> (Top-level wrapper for links) <links> can contain an arbitrary number of <link> tags, which act a wrapper used by the prelink, chunkload, and addtab transactions. Attributes None Contents <links> can contain an arbitrary number of <link> tags, which act a wrapper used by the prelink, chunkload, and addtab transactions to create a persistent link between two tables along a set of columns or to bring some subset of columns from a second table into the base table. Its basic syntax is given as follows. Example <links> <link table2=“foreign.table.name” col=“col1,col2” col2=“fcol1,fcol2” [denormalize=“1”] /> </links> This syntax specifies that the table referenced by the table2 attribute within the <link> tag should be joined along the columns indicated in the col and col2 attributes. If the denormalize attribute is present, columns from the foreign table are denormalized into the base table, otherwise a prelink between the two tables is generated. In the general case, any valid <link> operation that could be applied in the 1010data Macro Language can be included in the <links> block. <maxdown> (Download limit) The maximum amount of data that can be downloaded at one time. 1010data API Reference Manual | Table Tree | 62 Attributes None Contents The maximum number of data items (rows × columns) that a user of the 1010data web interface may download at one time. The download limit must be a non-negative whole number. <segmentation> (Specify the segmentation of a table) Specifies which columns should define the segmentation of a table. Attributes None Contents The <segmentation> container is used by the addtab and chunkload transactions to segment tables along the specified columns. Example <segmentation cols=”col1,col2” [advise=”0”]> <advise [sort=”1”] cols=”col1,col3”/> </segmentation> The cols attribute of <segmentation> specifies the columns to segment along. The <segmentation> block can contain an arbitrary number of <advise> tags. Each advise tag indicates that a particular sequence of columns is also sortseg or segby, given the segmentation enforced in the <segmentation> tag’s cols attribute. For example, if you have your table segby "day", then it is probably also segby "month". If for some reason you want to enforce segmentation by a particular column (or columns), but not to include it in the list of advised columns the “advise=0” attribute may be included in the <segmentation> tag. <table> (Top-level wrapper for table tree) The table tree is required and may have one attribute (name) and must contain certain elements. Attributes Attribute Value name Name of table If the table corresponds to a table in the 1010data system, this is the full path to the table in the 1010data database hierarchy. In general, a name has the form: directory1.directory2.....directoryn.table (similar to a Windows or Unix file-system path but with dots instead of slashes) The name of a table can be determined by clicking Help > About this Table in the 1010data web interface. Note the distinction between a table's name and its title (see <title> (Table title) on page 64). If the table does not correspond to a table in the 1010data system, name has no meaning and is omitted. 1010data API Reference Manual | Table Tree | 63 Example mycompany.folder.hourly95 Contents Each of the following elements is described in detail on its own page. <cols> and <data> are always present; the others may be omitted. Element Description <title> Title of table <sdesc> Short description of table <ldesc> Long description of table <link> Link header <maxdown> Download limit <cols> Column meta information <data> Table data <td> (One cell of data in a table) Returns the value of a single cell (column/row) of the table. Attributes None Contents The value of a single cell (column/row) of the table. The type of value (integer, float or alphanumeric) must conform to the column type as specified in the corresponding <th> entry under <cols>. <th> (Meta information for one column) The metadata for a single column in a table. Attributes Attribute Value name The name by which the column is referenced in formulas and query operations. Note that this is generally not the same as the column's heading (see "Contents" below). Ex. street type The type of data in the column. type must be one of: "i" (integer), "f" (float), or "a" (alphanumeric). format The display format for the data in the column. Format specifications have the same form as is used in the XML Macro Language used in the Edit Actions dialog of the 1010data web interface. Ex. type:num;width:15;dec:2 name and type must be present; format is optional. 1010data API Reference Manual | Table Tree | 64 Contents The column heading that appears above the column when the table is displayed in the 1010data web interface. Lines in the heading are separated by " " (the newline character). Example Street Address <title> (Table title) Returns the title of a table. The table title appears above the table when it is displayed in the 1010data web interface. Attributes None Contents The title of the table (i.e., the text that appears in both a directory listing and above the table when it is displayed in the 1010data web interface). For example, in the screenshot below, Sales Item Detail is the table title. 1010data API Reference Manual | Table Tree | 65 <tr> (Data for one row) The data for a single row in a table. Attributes None Contents <tr> specifies a row of table data. It must contain one <td> element for each column of the table, each of which contains the value for that column. The first <td> specifies a value for the first column listed in the <cols> element, the second <td> specifies a value for the second column, and so on. (See <cols> (Metadata for all columns) on page 58 and <td> (One cell of data in a table) on page 63.) 1010data API Reference Manual | Users Tree | 66 Users Tree The users tree is a way of representing access rights and is used in setting the access rights to a table that is saved or uploaded. The overall format is one of the following three options: <users type="inherit"/> or <users type="private"/> or <users type="list"> <user>username of first user</user> <user>username of second user</user> # <user>username of last user</user> </users> <users> (Top-level wrapper for users tree) The users tree may have one attribute (type) and, depending on the value of that attribute, may contain multiple instances of the <user> element. Attributes Attribute Value type The type of access specification type may have one of the following values: • • • private - No user, other than the table's owner, may access the table. list - Only the table's owner and users listed in the users tree may access the table. inherit - All users that have access to the table's parent directory may access the table. type is optional. If omitted, the default is private. A user with access to a table's parent directory, but not to the table itself, will not see the table in the directory's listing. Note that a user's access to any table is subject to the user's "maximum row limit." The largest table (in terms of number of rows) that a user may access is dependent on the user's subscription level. If a user is granted access to a table via the users tree, but the table has more rows than the user's maximum row limit, the user will see the table's title in the directory listing but will be unable to access it. Contents If type="private" or type="inherit", <users> must be empty. If type="list", <users> must contain one or more <user> elements, each identifying a single user or group. 1010data API Reference Manual | Users Tree | 67 <user> (User entry) The username or group name. The name provided must be a user or group that already exists in 1010data. Attributes None. Contents The username or group name. The name provided must be a user or group that already exists in 1010data. 1010data API Reference Manual | Field Data Types | 68 Field Data Types A field's data type may be one of the following: text Text (Picture) int Integer (Picture) float Float (Picture) 1Btext 1-Byte Char (Binary) 1Bint 1-Byte Int (Binary) 2Bint 2-Byte Int (Binary) 4Bint 4-Byte Int (Binary) 8Bint 8-Byte Int (Binary) 4Bfloat 4-Byte Float (Binary) 8Bfloat 8-Byte Double (Binary) dec Decimal (BCD) Signed Signed (= Zoned) YYYYMMDD Date YYMMDD Date MMDDYY Date DDMMYY Date MMDDYYYY Date DDMMYYYY Date YYYYMM Month/Year YYMM Month/Year MMYY Month/Year MMYYY Month/Year HHMM Time YYYYMMDDHHMMSS Date+Time All non-numeric characters in dates are ignored. For example, the following are equivalent: "31505" "3/15/05" "3-15-05" Input types YYYYMMDD and YYYYMM are tolerant of decoration characters (e.g., "2005-03-15" is the same as "20050315"). Upon load, dates are automatically converted to YYYYMMDD format, which is the format 1010data uses. Similarly, month/years are converted to YYYYMM. 1010data API Reference Manual | Field Format Types | 69 Field Format Types A field's display format may be one of the following: char Alphanumeric Text num Number: 1,234,567.89 nocommas Number: 1234567.89 date Date: 10/15/98 month Month/Year: 10/03 quarter Quarter/Year: 2Q03 hms24 Time: 22:45:56 datehms24 Date+Time: 10/15/98_22:45:56 1010data API Reference Manual | Deprecated Transactions | 70 Deprecated Transactions These transactions have been deprecated in the 1010data XML API. Please note that these transactions are still respected by the system and will not break your code. However, they have been superseded by other transactions with more functionality. The following table shows deprecated transactions and the transactions that should be used in their place. Deprecated Current rmdir drop rmtab drop timeseries savetable / addtab prelink savetable / addtab rmdir (Delete a directory) The rmdir transaction removes a directory. The API will check the permission of the user and the directory, and it will remove the directory only if the user is an owner of the parent directory. Finally, rmdir will only remove the directory if it is empty; therefore, be sure to remove all child tables and folders before invoking this transaction. Query String The query string in the HTTP header must contain the following parameters: Connection String Value Variable api rmdir apiversion 3 uid [USERNAME] pswd [ENCRYPTED PASSWORD] - returned from the login transaction sid [SESSION ID] (optional) - returned from the login transaction Query String Example api=rmdir&apiversion=3&uid=myid&pswd=Aiynnsewxhck&sid=1748453843 XML Input to Server The specifications must contain the following elements: XML Element To Send Description of Sent Element Content <name> The full path to the directory in the 1010data database hierarchy. In general, a path has the form: directory1.directory2.....directoryn.thisdirectory (similar to a Windows or Unix file-system path but with dots instead of slashes) 1010data API Reference Manual | Deprecated Transactions | 71 XML Input Example <in><name>mycompany.folder.yearly</name></in> XML Response from Server A successful rmdir produces the following result: <rc>0</rc> <msg>rmdir successful</msg> rmtab (Delete a table) The rmtab transaction removes a table from 1010data. The API will check the permission of the user and will remove the table if the user is an owner of the table. Query String The query string in the HTTP header must contain the following parameters: Connection String Value Variable api rmtab apiversion 3 uid [USERNAME] pswd [ENCRYPTED PASSWORD] - returned from the login transaction sid [SESSION ID] (optional) - returned from the login transaction Query String Example api=rmtab&apiversion=3&uid=myid&pswd=Aiynnsewxhck&sid=1748453843 XML Input to Server The specifications must contain the following elements: XML Element To Send Description of Sent Element Content <name> The full path to the table in the 1010data database hierarchy. In general, a path has the form: directory1.directory2.....directoryn.table (similar to a Windows or Unix file-system path but with dots instead of slashes) The name of a table can be determined by clicking Help > About this Table in the 1010data web interface. XML Input Example <in><name>mycompany.folder.yearly.tab</name></in> XML Response from Server A successful rmtab produces the following result: 1010data API Reference Manual | Deprecated Transactions | 72 <rc>0</rc> <msg>rmtab successful</msg> prelink (Prelink tables) The prelink transaction performs a link between two tables and persists the link result so ad hoc links are faster and less memory consumptive. Query String The query string in the HTTP header must contain the following parameters: Connection String Value Variable api prelink apiversion 3 uid [USERNAME] pswd [ENCRYPTED PASSWORD] - returned from the login transaction sid [SESSION ID] (optional) - returned from the login transaction Query String Example api=prelink&apiversion=3&uid=myid&pswd=Aiynnsewxhck&sid=1748453843 XML Element To Send Description of Sent Element Content <link> The main link element. The attributes of <link> provide the details for the link. The attributes are detailed in the next table. Attributes for <link> XML Element To Send Description of Sent Element Content table The base table (local table) for the link. table2 The table being "linked in," or the "foreign" table of the link. col The column being used to link in the original table. col2 The column being used to link in the foreign table. keepcols Tells the system to keep the cols in the original table. (optional) Accepts 1 for true or 0 for false. denormalize Accepts 1 for true or 0 for false. (optional) suffix Provides a suffix for the newly linked in columns. (optional) XML Input Example <in><link table=\"demos.table1\" table2=\"demos.table2\" col=\"symbol\" col2= \"symbol\" [keepcols=\"1\"] [denormalize=\"1\"] [suffix=\"foreign\"] /></in> 1010data API Reference Manual | Deprecated Transactions | 73 XML Response from Server XML Element To Send Description of Sent Element Content <rc> The return code. <msg> The message from the server. <numrecs> Number of records written to the table so far. Reported if addtab is in the loading state. <totrecs> Number of records in the source file. XML Response Example <rc>4</rc> <msg>Completed</msg> timeseries (Merge tables using time series) The timeseries transaction performs a time series process on one or multiple tables called source tables and creates a new table containing the merge of all the source tables on which one can execute g_ and tstat functions. Query String The query string in the HTTP header must contain the following parameters: Connection String Required Value Variable api timeseries apiversion 3 uid [USERNAME] pswd [ENCRYPTED PASSWORD] - returned from the login transaction sid [SESSION ID] (optional) - returned from the login transaction Query String Example api=timeseries&apiversion=3&uid=myid&pswd=Aiynnsewxhck&sid=1748453843 XML Input to Server The specifications must contain the following elements: XML Element To Send Description of Sent Element Content <name> The full path to the directory in the 1010data database hierarchy. In general, a path has the form: directory1.directory2.....directoryn.thisdirectory (similar to a Windows or Unix file-system path but with dots instead of slashes) <source> List of source tables 1010data API Reference Manual | Deprecated Transactions | 74 XML Element To Send Description of Sent Element Content <name> Table Name Element <title> Title as it appears in the user interface <link> A link header <users type=”list”> Users provisioned for table access. See Users Tree on page 66 for XML schema. <user></user> Excluding this element will set the table to inherit access rights. <breaks> List of source tables XML Input Example <in> <name>demos.auto_ts</name> <source> <name>demos.auto201001</name> <name>demos.auto201002</name> <name>demos.auto201003</name> </source> <title>auto ts</title> <link>link header</link> <users> <user>myuser1</user> <user>myuser2</user> </users> <breaks> <name>ownerid</name> <name>month</name> </breaks> </in> XML Response from Server A successful timeseries starts the process. Use the status transaction to keep track of its progress. <rc>0</rc> <msg>timeseries started</msg>
© Copyright 2024