Endpoints

Estimated reading: 4 minutes 2010 views

Let's talk about using the Endpoints

  • Points
  • Badges
  • Ranks

Points

Example Definition: POST http://yoursite.com/wp-json/mycred/v1/points

 
				
					{
"access_key": "",
"user_id": "",
"type": "",
"ctype": "",
"reference": "",
"amount": "",
"entry": ""
}
				
			

Example Request: curl -X POST http://yoursite.com/wp-json/mycred/v1/points -d “access_key=abcd123&user_id=1&type=get”


Parameters

Param Type Required Description
access_key string Yes

An authorization key to access myCred RESTful web service.

Default: None

user_id int Yes

The ID of the User getting the points.

Default: None

type string Yes

The action you want to perform. Pass “add” or “get”. Add to add points. Get to fetch points.

Default: None

ctype string No

The point type key. Should only be used if you are adjusting a custom point type and not the default one.

reference string No

The reference to log this entry. You can use your own custom reference OR one of the built-in.

Default: None

required if type == add

amount float No

The point amount to give to the User. This can be positive OR negative value.

Default: None

required if type == add

entry string No

The entry to save in the log for this adjustment.

Default: None

required if type == add

Badges

Example Definition: POST http://yoursite.com/wp-json/mycred/v1/badges

				
					{
"access_key": "",
"user_id": "",
"type": "",
"badge_id": "",
"badge_level": "",
}
				
			

Example Request: curl -X POST http://yoursite.com/wp-json/mycred/v1/badges -d “access_key=abcd123&user_id=1&type=get”


Parameters

Param Type Required Description
access_key string Yes

An authorization key to access myCred RESTful web service.

Default: None

user_id int Yes

The ID of the User getting the points. In case if there’s no user_id the service will return all badges with type get

Default: None

type string Yes

The action you want to perform. Get assign or unassign.

Default: None

badge_id int No

The ID of badge being assigned to the User.

Default: None

required if type == assign OR type == unassign

badge_level int No

The level of badge being assigned to the User.

Default: None

required if type == assign OR type == unassign

Ranks

Example Definition: POST http://yoursite.com/wp-json/mycred/v1/ranks

				
					{
"access_key": "",
"user_id": "",
"type": "",
"ctype": ""
}
				
			

Example Request: curl -X POST http://yoursite.com/wp-json/mycred/v1/ranks -d “access_key=abcd123&user_id=1&type=get”


Parameters

Param Type Required Description
access_key string Yes

An authorization key to access myCred RESTful web service.

Default: None

user_id int Yes

The ID of the User getting the points. In case if there’s no user_id the service will return all ranks with type get

Default: None

type string Yes

The action you want to perform. Get is the only type ranks handles.

Default: get

ctype string No

The point type key. Should only be used if you are adjusting a custom point type and not the default one.

References

Example Definition: POST http://yoursite.com/wp-json/mycred/v1/references

				
					{
"access_key": "",
"user_id": "",
"type": ""
}
				
			

Example Request: curl -X POST http://yoursite.com/wp-json/mycred/v1/references -d “access_key=abcd123&user_id=1&type=get”


Parameters

Param Type Required Description
access_key string Yes

An authorization key to access myCred RESTful web service.

Default: None

user_id int Yes

The ID of the User getting the points.

Default: None

type string Yes

The action you want to perform. Get is the only type references handles.

Default: get

				
					add_filter( 'mycred_all_references', 'mycredpro_add_custom_references' );
function mycredpro_add_custom_references( $list ) {
$list['my_reference'] = 'My Custom Reference';
return $list;
}