API Instructions

Sample Client Code

PHP

Authentication

In order to use the Ask 7Sigma API, you must first generate at least one set of API credentials, consisting of an API Key and an API secret. Your API Key is used to identify you, and your API Secret is used to sign your requests. You may currently have up to three sets of API credentials. If you have at least one question assigned to you, and are logged into your account, you can manage your API credentials using the button at the top of this page.

The Ask 7Sigma API uses a simplified custom version of OAuth 1.0a to authenticate your requests. For this, requests need to include a HTTP Authorization header that includes the api_key, signature, and signature_method parameters. The signature method is always HMAC-SHA256. A request to add a new answer to a question would look like this:

	POST /api/v1/questions/1/answers HTTP/1.1
	Host: ask.7sigma.com
	Accept: */*
	Authorization: Custom {"api_key":"B18FYKHdBWaOSlKGswegG8AfJnHT3","signature":"U2MGVjNzA4OGQwZGRhNGVjOTM3MDFlMTVlOGQ3OTkwZWM4MTNiNZTZlOTIyN2FlYmM3YjZmMWI4Mg==","signature_method":"HMAC-SHA256"}
	Content-Type: application/json
	Content-Length: 14
	

Signing Your Request

The 'signature' property is generated by you by first concatenating the (uppercase) method you're using, an '&' character, and the full URL that you're calling including any query parameters. If you are sending data using POST, PUT, or PATCH, you would follow this with another '&' character, and the json-encoded data that you're posting. For the request above, this would come out to:

	POST&https://ask.7sigma.com/api/v1/questions/1/answers&{"answer":42}
	

Once you've assembled this signature base string, you then need to calculate the signature using the HMAC-SHA256 hashing algorithm and your API Secret. The output from that is a binary value, which you then base64-encode to produce the signature string. To accomplish this in PHP, for example, you would do this:

	$signature = base64_encode(hash_hmac('sha256', $signature_base_string, $API_SECRET));
	

Question IDs

In the request URL above (https://ask.7sigma.com/api/v1/questions/1/answers), '1' represents the question ID. In order to determine the ID for the question you want to answer, you may call either https://ask.7sigma.com/api/v1/users or https://ask.7sigma.com/api/v1/questions. Both of these methods will show you information about the questions that belong to you, and the questions that are assigned to you. The question ID is also displayed preceding the question on your Home page

Current Available Methods

GET /users - View information about your user.

GET /questions - View information about your questions and your assigned questions.

GET /questions/<question ID> - View information about a specific question that belongs to you or is assigned to you.

GET /questions/<question ID>/answers - View all the answers to the specified question.

POST /questions/<question ID>/answers - Post a new answer to the specified question.

GET /questions/<question ID>/answers/<answer ID> - View a specific answer to the specified question.