Magi API 使用说明


鉴权机制

发起请求时,需在请求 headers 中添加 Authorization 字段。

Authorization 字段的值的格式为:APPCODE + 半角空格 +APPCODE值

其中 APPCODE值 为此前发送到您电子邮箱中的,32 个字符的十六进制字符串,且大小写敏感。

调用样例:

$ curl -X GET -H "Authorization:APPCODE 9cc873cfa72f5f6696f6c07c6f66d23d" \
"https://graph.api.magi.com/v1/facts"

APPCODE值 为统计 API 调用频次的唯一凭证,请勿泄露给第三方。当每日限额耗尽或授权过期时,API 服务将不再返回结果,而是 429 状态码。

若需额外的调用次数以进行评估,请联系 Peak Labs。

接口详情

graph/list_clue

方法协议路径描述
GEThttpsgraph.api.magi.com/v1/cluesReturn list of clues matching the given criteria
参数名参数位置类型必填默认值描述
skipQueryIntfalse0Number of resources to skip
limitQueryIntfalse10Maximum number of resources to return

graph/list_entity

方法协议路径描述
GEThttpsgraph.api.magi.com/v1/entitiesReturn list of entities matching the given criteria
参数名参数位置类型必填默认值描述
queryQueryStringfalse""Query string to search against
subjectQuery[]Stringfalse[]Filter resources matching one of the subjects
senseQueryStringfalse""Sense of the resources
orderQueryStringfalse""Sorting preference of sub-level resources
skipQueryIntfalse0Number of resources to skip
limitQueryIntfalse10Maximum number of resources to return

graph/list_fact

方法协议路径描述
GEThttpsgraph.api.magi.com/v1/factsReturn list of facts matching the given criteria
参数名参数位置类型必填默认值描述
queryQueryStringfalse""Query string to search against
schemeQueryStringfalse""Filter resources matching the scheme
subjectQuery[]Stringfalse[]Filter resources matching one of the subjects
predicateQuery[]Stringfalse[]Filter resources matching one of the predicate
objectQuery[]Stringfalse[]Filter resources matching one of the object
skipQueryIntfalse0Number of resources to skip
limitQueryIntfalse10Maximum number of resources to return

graph/list_node

方法协议路径描述
GEThttpsgraph.api.magi.com/v1/nodesReturn list of nodes matching the given criteria
参数名参数位置类型必填默认值描述
queryQueryStringfalse""Query string to search against
subjectQuery[]Stringfalse[]Filter resources matching one of the subjects
objectQuery[]Stringfalse[]Filter resources matching one of the object
skipQueryIntfalse0Number of resources to skip
limitQueryIntfalse10Maximum number of resources to return

graph/list_set

方法协议路径描述
GEThttpsgraph.api.magi.com/v1/setsReturn list of sets matching the given criteria
参数名参数位置类型必填默认值描述
queryQueryStringfalse""Query string to search against
schemeQueryStringfalse""Filter resources matching the scheme
subjectQuery[]Stringfalse[]Filter resources matching one of the subjects
predicateQuery[]Stringfalse[]Filter resources matching one of the predicate
objectQuery[]Stringfalse[]Filter resources matching one of the object
senseQueryStringfalse""Sense of the resources
orderQueryStringfalse""Sorting preference of sub-level resources
skipQueryIntfalse0Number of resources to skip
limitQueryIntfalse10Maximum number of resources to return

graph/list_teaser

方法协议路径描述
GEThttpsgraph.api.magi.com/v1/teasersReturn list of teasers matching the given criteria
参数名参数位置类型必填默认值描述
queryQueryStringfalse""Query string to search against
inclusiveQueryBooleanfalsetrueInclude exact matches
skipQueryIntfalse0Number of resources to skip
limitQueryIntfalse10Maximum number of resources to return

graph/get_clue

方法协议路径描述
GEThttpsgraph.api.magi.com/v1/clues/[id]Get clue by ID
参数名参数位置类型必填默认值描述
idPathStringtrue-ID of the target resource

graph/get_entity

方法协议路径描述
GEThttpsgraph.api.magi.com/v1/entities/[id]Get entity by ID
参数名参数位置类型必填默认值描述
idPathStringtrue-ID of the target resource

graph/get_fact

方法协议路径描述
GEThttpsgraph.api.magi.com/v1/facts/[id]Get fact by ID
参数名参数位置类型必填默认值描述
idPathStringtrue-ID of the target resource

graph/get_node

方法协议路径描述
GEThttpsgraph.api.magi.com/v1/nodes/[id]Get node by ID
参数名参数位置类型必填默认值描述
idPathStringtrue-ID of the target resource

graph/get_set

方法协议路径描述
GEThttpsgraph.api.magi.com/v1/sets/[id]Get set by ID
参数名参数位置类型必填默认值描述
idPathStringtrue-ID of the target resource

graph/get_teaser

方法协议路径描述
GEThttpsgraph.api.magi.com/v1/teasers/[id]Get tesaser by ID
参数名参数位置类型必填默认值描述
idPathStringtrue-ID of the target resource

返回值

返回值的结构大致相同,故不单独介绍。若想了解具体资源的详细信息,请开发者调用相应接口即可。

  • 列表类型成功返回:
    {
        "data": [
            {
                "_id": "xxx" // 资源的唯一 ID,用于单独 GET
                ...
            }, ...
        ]
    }
    
  • 资源类型成功返回:
    {
        // 单个资源的详情
    }
    
  • 失败返回:
    {
        "error":{
            "code": `HTTP_STATUS_CODE`,
            "message": `MESSAGE`
        }
    }