Solved

Gamification API, how to assing points to all users


Userlevel 3
Badge +2

I am just learning to use API and my first task is to assing points to users. I can see from documentation that I should add each and every user id.

I want to assing points to all users so how to do that?

 

 

icon

Best answer by Blastoise186 25 October 2022, 14:03

View original

10 replies

Badge

Heya!

I think you’d just have to make one API Call per user. So if you want to give 100 users 1 point each, you’ll need to make 100 API calls. There doesn’t seem to be a bulk assign option. If you can do an array though, you might be able to do all of them together at once - which would be preferable!

Userlevel 3
Badge +2

Okay, thanks, now I see.

Could you explain more about the array workaround?

Badge

I don’t really know anything about coding sadly, but I can tell you this much.

An array is basically a type of list. For example:

1

2

3

4

5

And so on. If you simply want to give everyone the same number of points at once, simply chuck ALL of their ID’s into an array as part of the API Call. Bear in mind the example in your screenshot queries how many points the requested users have. You can use an array for that one.

If you want to assign though, it’s one at a time.

 

Userlevel 3
Badge +2

Haha, then there is two of us - I dont do code :D

Yeah I want that platform (or API, or someone) calculates how many points each and every user has. We are just migrating our old community to inSided and I want that our users earn their points in the same time. They all have x amount of points and I want that they earn them (I dont want to start from scratch). Our gamification will be based on points, ranks also.

Badge

Gotcha!

In that case, there might be a more efficient route. If you’re using the migration service provided by inSided, it might be possible to migrate gamification data that way as well. It’d be WAY easier than messing with the API!

Userlevel 3
Badge +2

Yeah, we are using their migration service. Our onboarding & migration specialist recommend me to use API but maybe I ask nicely, once more, or ask maybe from Support :D

Badge

It never hurts to ask. :)

If you do end up using the API route, I strongly recommend testing it against your staging instance first. If you mess up in production, it’s almost impossible to take points away later!

I’d probably also suggest starting with the users who have the most Points first and working down from there. That way, the All-Time Leaderboard should stay fairly consistent but it will mess up the Weekly Leaderboard for any week where you’re still migrating. That will fix itself at the weekly reset anyway. And regardless of how you migrate the Points, it’ll all get sorted and organised automatically by the platform so you can even just do it in a random order if you want to.

Badge

Tell you what though… I spy a @Julian :)

I’ll ask if there’s other ways you can pull this off.

Userlevel 2
Badge +3

Thanks, @Blastoise186 - I spotted this Thread yesterday, so I already had it on my radar anyways. :P 

While I had a basic course on how to use an API myself, I would only recommend to work with the API if you have some experience with this. Otherwise it can become messy very quickly…

I have checked with my colleagues, hopefully support can help us to have this dealt with, so that we do not end up with users owning millions of points on the leaderboard. 😅

Userlevel 3
Badge +2

Thanks @Blastoise186  & @Julian. Yeah Support promised to do this for me, thanks this way as well :)

As said I havent ever used any API´s, so I need hands on teaching with that. It is good point to start with much easier task 🙂 But, I promise will learn how to use it and I will do things via API in the future!

Reply