StackExchangeAPI package
Need to include https://api.stackexchange.com/docs
StackExchangeAPI::usage="A symbol used for messages";StackExchangeInterface::usage="An interface to the API";$StackExchangeSites::usage="A set of stack exchange sites";
$SEAuthToken::usage= "A token that, if not none, will be passed to all API calls";$SECallQuota::usage="The overall stack exchange API call quota";$SECallsRemaining::usage="The stack exchange API calls remaining to a user";$SELastCall::usage="The last API call sent";$SECallCache::usage="The cache of all calls this session";$SEDefaultSite::usage="The default site to use";
SEUser::usage="A Stack Exchange user";SEQuestion::usage="A Stack Exchange question";SEAnswer::usage="A Stack Exchange answer";SEByID::usage="Converts an ID into a user, question, or answer";
SEBuildCall::usage="Constructs a call to the API";SECallAPI::usage="Calls the Stack Exchange API";
SEQuestions::usage="Searches for questions matching various parameters";SEAnswers::usage="Searches for answers matching various parameters";SEUsers::usage="Searches for users matching various parameters";SESearch::usage="A simplified search mechanism";
SECallInfo::usage="Turns a url into API call parameters";
SEAuthorize::usage= "Authorizes the app and sets the return value to $SEAuthToken";
SELookup::usage="Applies lookup to the association of the SE object";SEGather::usage="Gathers the fields for multiple calls";
SEImport::usage="Imports stuff from a SE page";SEChatScrape::usage="Scrapes data off a SE chat channel";
Begin["`Private`"];
$StackExchangeAPIRoot="api.stackexchange.com";$StackExchangeAPIVersion=2.2;
⌈API Usage⌋
Global Data
Global Data
Basic Calls
Basic Calls
Query Parameters
Query Parameters
APICallInfo
APICallInfo
SEByID
SEByID
SEUser
SEUser
SEQuestion
SEQuestion
SEAnswer
SEAnswer
SEQuestions
SEQuestions
SEAnswers
SEAnswers
SEUsers
SEUsers
SESearch
SESearch
SEImport
SEImport
SEChatScrape
SEChatScrape
chatURL[chatSpec__Integer]:= "https://chat.stackexchange.com/transcript/"<>(ToString/@{chatSpec});chatURL[url_String]:= With{p=URLParse@url}, chatURL@@ Replacep, {___,"transcript",spec__}{spec} ;
SEChatScrape[chatRoom_]:= Withts= ColumnFirst@First@#, Row@Spacer[10], RawBoxes@Cell[Thread[Last@#,TextData],"Text"], Dividers{{},{2Gray}}&/@ Partition SplitBy StringCases Import[chatURL@chatRoom,"Text"], u:("<div class=\"username\">"~~Shortest[__]~~"</div>") {"user",u}, "<div class=\"content\">"~~content:Shortest[__]~~"</div>" StringTrim@content(*ImportString[content,"HTML"]*) /. {"user",u_} First@StringCasesu, "href=\""~~link__~~"\" "~~__~~">"~~ name__~~"</a></div>" Hyperlink[name,"https://chat.stackexchange.com"<>link] , content_String TextData@ Append Replace StringReplacecontent, "<code>"~~code:Shortest[__]~~"</code>" StyleBox[code,"Input"], s_String {ImportString[s,"HTML"]}, StringExpression[bits__] Riffle ReplaceAll{bits}, s_StringImportString[s,"HTML"] , " " , "\n" , Head , 2, Column[ts,DividersCenter]~Style~(ShowStringCharactersFalse) //Panel
Authorization
Registered at https://stackapps.com/apps/oauth/view/8553
Base Data
Base Data
Auth Dialog
Auth Dialog
SEAuthorize
SEAuthorize
SEAuthorize[scope:_String|{__String}|Automatic:Automatic]:= Replace SEAuthDialog@scope, key_String?(StringLength@StringTrim@#>0&):> ($SEAuthToken=key) ;
Interface
StackExchangeInterface
StackExchangeInterface
Statistics