API for Candidate Information Management¶
Note: OnlineExamMaker API is only available for Premium users, if you want to request data from OnlineExamMaker API, please upgrade your account to Premium member.
1. Get candidate field information¶
Get candidate field information:¶
GET https://api.onlineexammaker.com/api/v1/student/getFields?code=xxx&time=current timestamp
Parameter:¶
code=authorization code&time=current timestamp
Parameter description:¶
-
code: Verification code is unique to each OnlineExamMaker account, Premium users can get it in "System Settings" -> "API & SSO Settings" in OnlineExamMaker dashoboard. (Related tutorial: How to get verification code for API?)
-
time: Current timestamp, for example: 1638768935.
-
Authorization: Please put Token in the request header, you can view the sample code for details. In simple terms: we concatenate the current timestamp and your code, and encrypt them with MD5.
If the operation is successful, the return value is:¶
{
"data":[
{
"sfid":1,
"label":"name"
},
{
"sfid":2,
"label":"gender"
},
{
"sfid":4,
"label":"phone"
},
{
"sfid":10,
"label":"password"
}
],
"status":"ok"
}
If the operation fails, the return value is:¶
Interface usage examples:¶
package main
import (
"crypto/md5"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"strconv"
"time"
)
const (
Code = "xxx"
)
func main() {
host := "https://api.onlineexammaker.com"
resource := "/api/v1/student/getFields"
client := &http.Client{}
fullPath := host + resource
req, _ := http.NewRequest(http.MethodGet, fullPath, nil)
time64 := time.Now().UTC().Unix()
ParseToken := fmt.Sprintf("%x", md5.Sum([]byte(strconv.FormatInt(time64, 10)+Code)))
req.Header.Set("Authorization", ParseToken)
q := req.URL.Query()
q.Add("code", Code)
q.Add("time", strconv.Itoa(int(time64)))
req.URL.RawQuery = q.Encode()
resp, err := client.Do(req)
if err != nil {
log.Println(err)
return
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Println(err)
return
}
// fmt.Println(string(b))
f, _ := os.OpenFile("test.txt", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
f.Write(b)
}
2. Batch insert candidate information¶
Batch insert candidate information:¶
POST https://api.onlineexammaker.com/api/v1/student/addStudents
Parameter:¶
code=authorization code&time=current timestamp
Parameter description:¶
-
code: Verification code is unique to each OnlineExamMaker account, Premium users can get it in "System Settings" -> "API & SSO Settings" in OnlineExamMaker dashoboard. (Related tutorial: How to get verification code for API?)
-
time: Current timestamp, for example: 1638768935.
-
info: The candidate information value you want to insert.
-
Authorization: Token is in the request header, you can view the sample code for details. In simple terms: we concatenate the current timestamp and your code, and encrypt them with MD5.
If the operation is successful, the return value is:¶
{
"fail":[
//If the insertion fails, return the index of the array.
],
"status":"ok",
"success":[//Data successfully inserted...
{
"sid":170603,//Student's sid after insertion
"index":1 //The location of the data where the data is passed in
},
{
"sid":170604,
"index":2
}
]
}
If the operation fails, the return value is:¶
Interface usage examples:¶
package main
import (
"crypto/md5"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
"os"
"strconv"
"strings"
"time"
)
const (
Code = "xxx"
)
func main() {
host := "https://api.onlineexammaker.com"
resource := "/api/v1/student/addStudents"
client := &http.Client{}
fullPath := host + resource
info := `
[
{
"gid": "2993",
"fields": [
{
"sfid": 4,
"value": "2993"
},
{
"sfid": 1,
"value": "stufor2993"
}
]
},
{
"gid": "2994",
"fields": [
{
"sfid": 10,
"value": "2994"
},
{
"sfid": 1,
"value": "stufor2994"
}
]
}
]
`
time64 := time.Now().UTC().Unix()
data := make(url.Values)
data["code"] = []string{Code}
data["info"] = []string{info}
data["time"] = []string{strconv.Itoa(int(time64))}
req, _ := http.NewRequest(http.MethodPost, fullPath, strings.NewReader(data.Encode()))
ParseToken := fmt.Sprintf("%x", md5.Sum([]byte(strconv.FormatInt(time64, 10)+Code)))
req.Header.Set("Authorization", ParseToken)
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
resp, err := client.Do(req)
if err != nil {
log.Println(err)
return
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Println(err)
return
}
fmt.Println(string(b))
f, _ := os.OpenFile("test.txt", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
f.Write(b)
}
3. Modify candidate information in batches¶
Modify candidate information in batches:¶
POST https://api.onlineexammaker.com/api/v1/student/changeStuinfo
Parameter:¶
code=authorization code&time=current timestamp
Parameter description:¶
-
code: Verification code is unique to each OnlineExamMaker account, Premium users can get it in "System Settings" -> "API & SSO Settings" in OnlineExamMaker dashoboard. (Related tutorial: How to get verification code for API?)
-
time: Current timestamp, for example: 1638768935.
-
info: The candidate information value you want to modify.
-
Authorization: Token is in the request header, you can view the sample code for details. In simple terms: we concatenate the current timestamp and your code, and encrypt them with MD5.
If the operation is successful, the return value is:¶
{
"fail":[
//If the operaton fails, return the index of the array.
],
"status":"ok",
"success":[
"170603",//The student ID (sid) that is modified successfully
"170604"
]
}
If the operation fails, the return value is:¶
Interface usage examples:¶
package main
import (
"crypto/md5"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
"os"
"strconv"
"strings"
"time"
)
const (
Code = "xxx"
)
func main() {
host := "https://api.onlineexammaker.com"
resource := "/api/v1/student/changeStuinfo"
client := &http.Client{}
fullPath := host + resource
info := `
[
{
"sid":170603,
"loginValue": "",
"fields": [
{
"sfid": 1,
"value": "stufor2993change"
},
{
"sfid": 4,
"value": "18320320xxx"
}
]
},
{
"sid":170604,
"loginValue": "",
"fields": [
{
"sfid": 1,
"value": "stufor2994change"
},
{
"sfid": 10,
"value": "29944"
}
]
}
]
`
time64 := time.Now().UTC().Unix()
data := make(url.Values)
data["code"] = []string{Code}
data["info"] = []string{info}
data["time"] = []string{strconv.Itoa(int(time64))}
req, _ := http.NewRequest(http.MethodPost, fullPath, strings.NewReader(data.Encode()))
ParseToken := fmt.Sprintf("%x", md5.Sum([]byte(strconv.FormatInt(time64, 10)+Code)))
req.Header.Set("Authorization", ParseToken)
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
resp, err := client.Do(req)
if err != nil {
log.Println(err)
return
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Println(err)
return
}
fmt.Println(string(b))
f, _ := os.OpenFile("test.txt", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
f.Write(b)
}
4. Delete candidate information in batches¶
Batch delete candidate information:¶
POST https://api.onlineexammaker.com/api/v1/student/delStu
Parameter:¶
code=authorization code&time=current timestamp&sids=student id(use filed a or field b here)
Parameter description:¶
-
code: Verification code is unique to each OnlineExamMaker account, Premium users can get it in "System Settings" -> "API & SSO Settings" in OnlineExamMaker dashoboard. (Related tutorial: How to get verification code for API?)
-
time: Current timestamp, for example: 1638768935.
-
sids(field a): Student unique id. The format is as follows: [170603,170604]. You can also refer to the example code.
-
loginValues(field b): The login fields that set by the administrator, such as name, mobile phone, etc. The format is as follows: ["James","Hery"]. You can also refer to the example code.
-
Authorization: Please put Token in the request header, you can view the sample code for details. In simple terms: we concatenate the current timestamp and your code, and encrypt them with MD5.
If the operation is successful, the return value is:¶
{
"fail":[
//If the operaton fails, return the index of the array.
],
"status":"ok",
"success":[
"170603",//The student ID (sid) that is deleted successfully
"170604"
]
}
If the operation fails, the return value is:¶
Interface usage examples:¶
package main
import (
"crypto/md5"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
"os"
"strconv"
"strings"
"time"
)
const (
Code = "xxx"
)
func main() {
host := "https://api.onlineexammaker.com"
resource := "/api/v1/student/delStu"
client := &http.Client{}
fullPath := host + resource
sids := "[170603,170604]"
// loginValues := "[\"login field xx\",\"login field xxx\"]"
time64 := time.Now().UTC().Unix()
data := make(url.Values)
data["code"] = []string{Code}
data["sids"] = []string{sids}
// data["loginValues"] = []string{loginValues}
data["time"] = []string{strconv.Itoa(int(time64))}
req, _ := http.NewRequest(http.MethodPost, fullPath, strings.NewReader(data.Encode()))
ParseToken := fmt.Sprintf("%x", md5.Sum([]byte(strconv.FormatInt(time64, 10)+Code)))
req.Header.Set("Authorization", ParseToken)
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
resp, err := client.Do(req)
if err != nil {
log.Println(err)
return
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Println(err)
return
}
fmt.Println(string(b))
f, _ := os.OpenFile("test.txt", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
f.Write(b)
}
5. Move candidates to a group¶
Move candidates to a group:¶
POST https://api.onlineexammaker.com/api/v1/student/movestugroup
Parameter:¶
code=authorization code&time=current timestamp
Parameter description:¶
-
code: Verification code is unique to each OnlineExamMaker account, Premium users can get it in "System Settings" -> "API & SSO Settings" in OnlineExamMaker dashoboard. (Related tutorial: How to get verification code for API?)
-
time: Current timestamp, for example: 1638768935.
-
mvStuInfo: Please refer to the sample code and select either loginValues or sid.
-
Authorization: Please put Token in the request header, you can view the sample code for details. In simple terms: we concatenate the current timestamp and your code, and encrypt them with MD5.
If the operation is successful, the return value is:¶
{
"fail":[
//If the operaton fails, return the index of the array.
],
"status":"ok",
"success":[
"170606",//The student ID (sid) that is moved to a group successfully
"170607"
]
}
If the operation fails, the return value is:¶
Interface usage examples:¶
package main
import (
"crypto/md5"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
"os"
"strconv"
"strings"
"time"
)
const (
Code = "xxx"
)
func main() {
host := "https://api.onlineexammaker.com"
resource := "/api/v1/student/movestugroup"
client := &http.Client{}
fullPath := host + resource
mvStuInfo := `
{
"gids": [2993],
"loginValues":[],
"sid":[170606,170607],
"action": "moveto"
}
`
/*
Take sid as an example. If loginValues is used, the format is as follows ["Login field 1", "Login field 2"]
action: Contain actions like addto, moveto, delfrom.
addto: Adding candidates to a group. At this time, a candidate may exist in multiple groups.
moveto: Moving candidates to a group. At this time, the candidate only exists in the passed group.
delfrom: Removing the candidate from the specified group. Please note that the candidate should still exist in at least one group after removal, otherwise the removal will fail.
*/
time64 := time.Now().UTC().Unix()
data := make(url.Values)
data["code"] = []string{Code}
data["mvStuInfo"] = []string{mvStuInfo}
data["time"] = []string{strconv.Itoa(int(time64))}
req, _ := http.NewRequest(http.MethodPost, fullPath, strings.NewReader(data.Encode()))
ParseToken := fmt.Sprintf("%x", md5.Sum([]byte(strconv.FormatInt(time64, 10)+Code)))
req.Header.Set("Authorization", ParseToken)
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
resp, err := client.Do(req)
if err != nil {
log.Println(err)
return
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Println(err)
return
}
fmt.Println(string(b))
f, _ := os.OpenFile("test.txt", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
f.Write(b)
}
6. Get candidate information¶
Get candidate information:¶
POST https://api.onlineexammaker.com/api/v1/student/getstudentsinfo
Parameter:¶
code=authorization code&time=current timestamp
Parameter description:¶
-
code: Verification code is unique to each OnlineExamMaker account, Premium users can get it in "System Settings" -> "API & SSO Settings" in OnlineExamMaker dashoboard. (Related tutorial: How to get verification code for API?)
-
time: Current timestamp, for example: 1638768935.
-
loginValues(one of the two fields): The login fields that set by the administrator, such as name, mobile phone, etc. The format is as follows: ["James","Hery"]. You can also refer to the example code.
-
sids(one of the two fields): Student unique id. The format is as follows: [170603,170604]. You can also refer to the example code.
-
Authorization: Please put Token in the request header, you can view the sample code for details. In simple terms: we concatenate the current timestamp and your code, and encrypt them with MD5.
If the operation is successful, the return value is:¶
{
"data":[
{
"sid":170605,
"fields":[
{
"sFid":1,
"label":"name",
"value":"newstufor2993"
}
],
"group":[
{
"gid":2993,
"title":"2993"
}
]
},
{
"sid":170606,
"fields":[
{
"sFid":1,
"label":"name",
"value":"newstufor2994"
}
],
"group":[
{
"gid":2993,
"title":"2993"
}
]
}
],
"fail":[
//If it fails, return the corresponding sid or loginValues. This may be because the candidate has been deleted.
],
"status":"ok"
}
If the operation fails, the return value is:¶
Interface usage examples:¶
package main
import (
"crypto/md5"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
"os"
"strconv"
"strings"
"time"
)
const (
Code = "xxx"
)
func main() {
host := "https://api.onlineexammaker.com"
resource := "/api/v1/student/getstudentsinfo"
client := &http.Client{}
fullPath := host + resource
// sids := "[170603,170604]"
sids := "[170605,170606]"
// loginValues := "[\"login field xx\",\"login field xxx\"]"
time64 := time.Now().UTC().Unix()
data := make(url.Values)
data["code"] = []string{Code}
data["sids"] = []string{sids}
// data["loginValues"] = []string{loginValues}
data["time"] = []string{strconv.Itoa(int(time64))}
req, _ := http.NewRequest(http.MethodPost, fullPath, strings.NewReader(data.Encode()))
ParseToken := fmt.Sprintf("%x", md5.Sum([]byte(strconv.FormatInt(time64, 10)+Code)))
req.Header.Set("Authorization", ParseToken)
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
resp, err := client.Do(req)
if err != nil {
log.Println(err)
return
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Println(err)
return
}
fmt.Println(string(b))
f, _ := os.OpenFile("test.txt", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
f.Write(b)
}
7. Get the list of candidates¶
Get the list of candidates:¶
POST https://api.onlineexammaker.com/api/v1/student/getstulist
Parameter:¶
code=authorization code&time=current timestamp
Parameter description:¶
-
code: Verification code is unique to each OnlineExamMaker account, Premium users can get it in "System Settings" -> "API & SSO Settings" in OnlineExamMaker dashoboard. (Related tutorial: How to get verification code for API?)
-
time: Current timestamp, for example: 1638768935.
-
start: Paging parameter.
-
limit: The quantity of queries. The maximum number of queries is 100.
-
Authorization: Please put Token in the request header, you can view the sample code for details. In simple terms: we concatenate the current timestamp and your code, and encrypt them with MD5.
If the operation is successful, the return value is:¶
{
"data":[
{
"loginValue":"newstufor2993",
"fields":[
{
"sFid":1,
"label":"name",
"value":"newstufor2993"
},
{
"sFid":4,
"label":"phone",
"value":"2993"
}
]
},
{
"loginValue":"newstufor2994",
"fields":[
{
"sFid":1,
"label":"name",
"value":"newstufor2994"
},
{
"sFid":10,
"label":"password",
"value":"2994"
}
]
},
{
"loginValue":"newstufor29942",
"fields":[
{
"sFid":1,
"label":"name",
"value":"newstufor29942"
},
{
"sFid":10,
"label":"password",
"value":"2994"
}
]
}
],
"status":"ok",
"total":12
}
If the operation fails, the return value is:¶
Interface usage examples:¶
package main
import (
"crypto/md5"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
"os"
"strconv"
"strings"
"time"
)
const (
Code = "xxx"
)
func main() {
host := "https://api.onlineexammaker.com"
resource := "/api/v1/student/getstulist"
client := &http.Client{}
fullPath := host + resource
time64 := time.Now().UTC().Unix()
data := make(url.Values)
data["code"] = []string{Code}
data["start"] = []string{"0"}
data["limit"] = []string{"3"}
data["time"] = []string{strconv.Itoa(int(time64))}
req, _ := http.NewRequest(http.MethodPost, fullPath, strings.NewReader(data.Encode()))
ParseToken := fmt.Sprintf("%x", md5.Sum([]byte(strconv.FormatInt(time64, 10)+Code)))
req.Header.Set("Authorization", ParseToken)
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
resp, err := client.Do(req)
if err != nil {
log.Println(err)
return
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Println(err)
return
}
fmt.Println(string(b))
f, _ := os.OpenFile("test.txt", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
f.Write(b)
}
8. Get the test records of all candidates or a single candidate¶
Get the list of candidates:¶
GET https://api.onlineexammaker.com/api/v1/student/queryresults
Parameter:¶
code=authorization code&time=current timestamp
Parameter description:¶
-
code: Verification code is unique to each OnlineExamMaker account, Premium users can get it in "System Settings" -> "API & SSO Settings" in OnlineExamMaker dashoboard. (Related tutorial: How to get verification code for API?)
-
time: Current timestamp, for example: 1638768935.
-
start: Paging parameter.
-
limit: The quantity of queries. The maximum number of queries is 100.
-
loginValues: If you need to query the test records of a single candidate, you must use it with eid.
-
eid: If you need to query the test records of a single candidate, you need to use it with loginValues. You can view the sample code for details.
-
Authorization: Please put Token in the request header, you can view the sample code for details. In simple terms: we concatenate the current timestamp and your code, and encrypt them with MD5.
If the operation is successful, the return value is:¶
{
"data":[
{
"viewResult":"https://api.onlineexammaker.com/transgetresult?tid=xxx\u0026token=xxx", //Test paper details link, the symbol '&' should be replaced with '\u0026'.
"score":"2",//Score
"passed":"0",//Pass the exam or not
"status":"1",
"startTime":"1639647217",//Exam start tiem
"endTime":"1639647236",//Exam end tiem
"sid":"170597",
"loginValue":"n11",//login field
"name":"n11",//candidate name
"eid":"107264"//exam id
},
{
"viewResult":"https://api.onlineexammaker.com/transgetresult?tid=xxx\u0026token=xxx",
"score":"1",
"passed":"0",
"status":"1",
"startTime":"1639647122",
"endTime":"1639647132",
"sid":"170597",
"loginValue":"n11",
"name":"n11",
"eid":"107264"
}
],
"status":"ok",
"total":1877
}
If the operation fails, the return value is:¶
Interface usage examples:¶
package main
import (
"crypto/md5"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"strconv"
"time"
)
const (
Code = "xxx"
)
func main() {
host := "https://api.onlineexammaker.com"
resource := "/api/v1/student/queryresults"
client := &http.Client{}
fullPath := host + resource
req, _ := http.NewRequest(http.MethodGet, fullPath, nil)
time64 := time.Now().UTC().Unix()
ParseToken := fmt.Sprintf("%x", md5.Sum([]byte(strconv.FormatInt(time64, 10)+Code)))
req.Header.Set("Authorization", ParseToken)
q := req.URL.Query()
q.Add("code", Code)
q.Add("start", "0")
q.Add("limit", "2")
// ↑↑Get all candidates' exam data↑↑
// ↓↓Get the exam taken record of a single candidate↓↓
// q.Add("loginValues", "n11")
// q.Add("eid", "107264")
q.Add("time", strconv.Itoa(int(time64)))
req.URL.RawQuery = q.Encode()
resp, err := client.Do(req)
if err != nil {
log.Println(err)
return
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Println(err)
return
}
// fmt.Println(string(b))
f, _ := os.OpenFile("test.txt", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
f.Write(b)
}