brew tap GetStream/stream-cli https://github.com/GetStream/stream-cli
brew install stream-cli
Import Files
Imports are not entirely supported on V3. This page is a work in progress.
If you’ve just started using Stream, you might want to import data from your old infrastructure. Instead of using the APIs and creating your own import scripts, you can make use of our import feature.
The Process
The steps for importing data into your app are as follows:
Install the CLI
Setup your app
stream-cli config new
stream-cli feeds import-validate myfile.json
stream-cli feeds import --apikey 123 myfile.json
stream-cli feeds import-status
Users
Users are shared with chat and video. So if you already use those products you typically don’t need to import users. The structure for importing users is shown below:
{
"users": [
{
"id": "myuserid",
"role": "user",
"custom": {}
}
]
}
activities := []getstream.ActivityRequest{
{
Type: "post",
Text: getstream.PtrTo("Batch activity 1"),
UserID: &testUserID,
},
{
Type: "post",
Text: getstream.PtrTo("Batch activity 2"),
UserID: &testUserID,
},
}
response, err := feedsClient.UpsertActivities(ctx, &getstream.UpsertActivitiesRequest{
Activities: activities,
})
List<ActivityRequest> activities =
List.of(
ActivityRequest.builder()
.type("post")
.text("Batch activity 1")
.userID(testUserId)
.build(),
ActivityRequest.builder()
.type("post")
.text("Batch activity 2")
.userID(testUserId)
.build());
UpsertActivitiesRequest request =
UpsertActivitiesRequest.builder().activities(activities).build();
UpsertActivitiesResponse response = feeds.upsertActivities(request).execute().getData();
$activities = [
[
'type' => 'post',
'text' => 'Batch activity 1',
'user_id' => $this->testUserId,
],
[
'type' => 'post',
'text' => 'Batch activity 2',
'user_id' => $this->testUserId,
]
];
$response = $this->feedsV3Client->upsertActivities(
new GeneratedModels\UpsertActivitiesRequest(activities: $activities)
);
var activities = new List<ActivityRequest>
{
new ActivityRequest
{
Type = "post",
Text = "Batch activity 1",
UserID = _testUserId
},
new ActivityRequest
{
Type = "post",
Text = "Batch activity 2",
UserID = _testUserId
}
};
var response = await _feedsV3Client.UpsertActivitiesAsync(
new UpsertActivitiesRequest { Activities = activities }
);
activities = [
ActivityRequest(
type="post",
text="Batch activity 1",
user_id=self.test_user_id,
feeds=[self.test_feed.get_feed_identifier()],
),
ActivityRequest(
type="post",
text="Batch activity 2",
user_id=self.test_user_id,
feeds=[self.test_feed.get_feed_identifier()],
),
]
response = self.client.feeds.upsert_activities(activities=activities)
Feeds
This is how you can import activities to a feed.
{
"feeds": [
{
"id": "myid",
"group": "post",
"name": "myuserid",
"description": ["feed:123"],
"visibility": "",
"custom": {}
}
]
}
activities := []getstream.ActivityRequest{
{
Type: "post",
Text: getstream.PtrTo("Batch activity 1"),
UserID: &testUserID,
},
{
Type: "post",
Text: getstream.PtrTo("Batch activity 2"),
UserID: &testUserID,
},
}
response, err := feedsClient.UpsertActivities(ctx, &getstream.UpsertActivitiesRequest{
Activities: activities,
})
List<ActivityRequest> activities =
List.of(
ActivityRequest.builder()
.type("post")
.text("Batch activity 1")
.userID(testUserId)
.build(),
ActivityRequest.builder()
.type("post")
.text("Batch activity 2")
.userID(testUserId)
.build());
UpsertActivitiesRequest request =
UpsertActivitiesRequest.builder().activities(activities).build();
UpsertActivitiesResponse response = feeds.upsertActivities(request).execute().getData();
$activities = [
[
'type' => 'post',
'text' => 'Batch activity 1',
'user_id' => $this->testUserId,
],
[
'type' => 'post',
'text' => 'Batch activity 2',
'user_id' => $this->testUserId,
]
];
$response = $this->feedsV3Client->upsertActivities(
new GeneratedModels\UpsertActivitiesRequest(activities: $activities)
);
var activities = new List<ActivityRequest>
{
new ActivityRequest
{
Type = "post",
Text = "Batch activity 1",
UserID = _testUserId
},
new ActivityRequest
{
Type = "post",
Text = "Batch activity 2",
UserID = _testUserId
}
};
var response = await _feedsV3Client.UpsertActivitiesAsync(
new UpsertActivitiesRequest { Activities = activities }
);
activities = [
ActivityRequest(
type="post",
text="Batch activity 1",
user_id=self.test_user_id,
feeds=[self.test_feed.get_feed_identifier()],
),
ActivityRequest(
type="post",
text="Batch activity 2",
user_id=self.test_user_id,
feeds=[self.test_feed.get_feed_identifier()],
),
]
response = self.client.feeds.upsert_activities(activities=activities)
See the feeds docs for all supported fields
Activities
This is how you can import activities to a feed.
{
"activities": [
{
"id": "myid",
"type": "post",
"user_id": "myuserid",
"feed_ids": ["feed:123"],
"text": "hi",
"attachments": [],
"visibility": "public",
"visibility_tag": "premium",
"custom": {}
}
]
}
activities := []getstream.ActivityRequest{
{
Type: "post",
Text: getstream.PtrTo("Batch activity 1"),
UserID: &testUserID,
},
{
Type: "post",
Text: getstream.PtrTo("Batch activity 2"),
UserID: &testUserID,
},
}
response, err := feedsClient.UpsertActivities(ctx, &getstream.UpsertActivitiesRequest{
Activities: activities,
})
List<ActivityRequest> activities =
List.of(
ActivityRequest.builder()
.type("post")
.text("Batch activity 1")
.userID(testUserId)
.build(),
ActivityRequest.builder()
.type("post")
.text("Batch activity 2")
.userID(testUserId)
.build());
UpsertActivitiesRequest request =
UpsertActivitiesRequest.builder().activities(activities).build();
UpsertActivitiesResponse response = feeds.upsertActivities(request).execute().getData();
$activities = [
[
'type' => 'post',
'text' => 'Batch activity 1',
'user_id' => $this->testUserId,
],
[
'type' => 'post',
'text' => 'Batch activity 2',
'user_id' => $this->testUserId,
]
];
$response = $this->feedsV3Client->upsertActivities(
new GeneratedModels\UpsertActivitiesRequest(activities: $activities)
);
var activities = new List<ActivityRequest>
{
new ActivityRequest
{
Type = "post",
Text = "Batch activity 1",
UserID = _testUserId
},
new ActivityRequest
{
Type = "post",
Text = "Batch activity 2",
UserID = _testUserId
}
};
var response = await _feedsV3Client.UpsertActivitiesAsync(
new UpsertActivitiesRequest { Activities = activities }
);
activities = [
ActivityRequest(
type="post",
text="Batch activity 1",
user_id=self.test_user_id,
feeds=[self.test_feed.get_feed_identifier()],
),
ActivityRequest(
type="post",
text="Batch activity 2",
user_id=self.test_user_id,
feeds=[self.test_feed.get_feed_identifier()],
),
]
response = self.client.feeds.upsert_activities(activities=activities)
See the activity docs for all supported fields
Follows
For follows specify the import in the following structure:
{
"follows": [
{
"source": "feed:123",
"target": "feed:222",
"custom": {},
"push_preference": "none"
}
]
}
activities := []getstream.ActivityRequest{
{
Type: "post",
Text: getstream.PtrTo("Batch activity 1"),
UserID: &testUserID,
},
{
Type: "post",
Text: getstream.PtrTo("Batch activity 2"),
UserID: &testUserID,
},
}
response, err := feedsClient.UpsertActivities(ctx, &getstream.UpsertActivitiesRequest{
Activities: activities,
})
List<ActivityRequest> activities =
List.of(
ActivityRequest.builder()
.type("post")
.text("Batch activity 1")
.userID(testUserId)
.build(),
ActivityRequest.builder()
.type("post")
.text("Batch activity 2")
.userID(testUserId)
.build());
UpsertActivitiesRequest request =
UpsertActivitiesRequest.builder().activities(activities).build();
UpsertActivitiesResponse response = feeds.upsertActivities(request).execute().getData();
$activities = [
[
'type' => 'post',
'text' => 'Batch activity 1',
'user_id' => $this->testUserId,
],
[
'type' => 'post',
'text' => 'Batch activity 2',
'user_id' => $this->testUserId,
]
];
$response = $this->feedsV3Client->upsertActivities(
new GeneratedModels\UpsertActivitiesRequest(activities: $activities)
);
var activities = new List<ActivityRequest>
{
new ActivityRequest
{
Type = "post",
Text = "Batch activity 1",
UserID = _testUserId
},
new ActivityRequest
{
Type = "post",
Text = "Batch activity 2",
UserID = _testUserId
}
};
var response = await _feedsV3Client.UpsertActivitiesAsync(
new UpsertActivitiesRequest { Activities = activities }
);
activities = [
ActivityRequest(
type="post",
text="Batch activity 1",
user_id=self.test_user_id,
feeds=[self.test_feed.get_feed_identifier()],
),
ActivityRequest(
type="post",
text="Batch activity 2",
user_id=self.test_user_id,
feeds=[self.test_feed.get_feed_identifier()],
),
]
response = self.client.feeds.upsert_activities(activities=activities)
Members
For follows specify the import in the following structure:
{
"members": [
{
"user_id": "user:123",
"feed": "feed:222",
"custom": {},
"role": ""
}
]
}
activities := []getstream.ActivityRequest{
{
Type: "post",
Text: getstream.PtrTo("Batch activity 1"),
UserID: &testUserID,
},
{
Type: "post",
Text: getstream.PtrTo("Batch activity 2"),
UserID: &testUserID,
},
}
response, err := feedsClient.UpsertActivities(ctx, &getstream.UpsertActivitiesRequest{
Activities: activities,
})
List<ActivityRequest> activities =
List.of(
ActivityRequest.builder()
.type("post")
.text("Batch activity 1")
.userID(testUserId)
.build(),
ActivityRequest.builder()
.type("post")
.text("Batch activity 2")
.userID(testUserId)
.build());
UpsertActivitiesRequest request =
UpsertActivitiesRequest.builder().activities(activities).build();
UpsertActivitiesResponse response = feeds.upsertActivities(request).execute().getData();
$activities = [
[
'type' => 'post',
'text' => 'Batch activity 1',
'user_id' => $this->testUserId,
],
[
'type' => 'post',
'text' => 'Batch activity 2',
'user_id' => $this->testUserId,
]
];
$response = $this->feedsV3Client->upsertActivities(
new GeneratedModels\UpsertActivitiesRequest(activities: $activities)
);
var activities = new List<ActivityRequest>
{
new ActivityRequest
{
Type = "post",
Text = "Batch activity 1",
UserID = _testUserId
},
new ActivityRequest
{
Type = "post",
Text = "Batch activity 2",
UserID = _testUserId
}
};
var response = await _feedsV3Client.UpsertActivitiesAsync(
new UpsertActivitiesRequest { Activities = activities }
);
activities = [
ActivityRequest(
type="post",
text="Batch activity 1",
user_id=self.test_user_id,
feeds=[self.test_feed.get_feed_identifier()],
),
ActivityRequest(
type="post",
text="Batch activity 2",
user_id=self.test_user_id,
feeds=[self.test_feed.get_feed_identifier()],
),
]
response = self.client.feeds.upsert_activities(activities=activities)
Comments
For reactions specify the import in the following structure:
{
"comments": [
{
"object_id": "123",
"object_type": "456",
"comment": "buy a gaming chair",
"attachments": [],
"mentioned_user_ids": ["user:222"],
"parent_id": null,
"custom": {}
}
]
}
activities := []getstream.ActivityRequest{
{
Type: "post",
Text: getstream.PtrTo("Batch activity 1"),
UserID: &testUserID,
},
{
Type: "post",
Text: getstream.PtrTo("Batch activity 2"),
UserID: &testUserID,
},
}
response, err := feedsClient.UpsertActivities(ctx, &getstream.UpsertActivitiesRequest{
Activities: activities,
})
List<ActivityRequest> activities =
List.of(
ActivityRequest.builder()
.type("post")
.text("Batch activity 1")
.userID(testUserId)
.build(),
ActivityRequest.builder()
.type("post")
.text("Batch activity 2")
.userID(testUserId)
.build());
UpsertActivitiesRequest request =
UpsertActivitiesRequest.builder().activities(activities).build();
UpsertActivitiesResponse response = feeds.upsertActivities(request).execute().getData();
$activities = [
[
'type' => 'post',
'text' => 'Batch activity 1',
'user_id' => $this->testUserId,
],
[
'type' => 'post',
'text' => 'Batch activity 2',
'user_id' => $this->testUserId,
]
];
$response = $this->feedsV3Client->upsertActivities(
new GeneratedModels\UpsertActivitiesRequest(activities: $activities)
);
var activities = new List<ActivityRequest>
{
new ActivityRequest
{
Type = "post",
Text = "Batch activity 1",
UserID = _testUserId
},
new ActivityRequest
{
Type = "post",
Text = "Batch activity 2",
UserID = _testUserId
}
};
var response = await _feedsV3Client.UpsertActivitiesAsync(
new UpsertActivitiesRequest { Activities = activities }
);
activities = [
ActivityRequest(
type="post",
text="Batch activity 1",
user_id=self.test_user_id,
feeds=[self.test_feed.get_feed_identifier()],
),
ActivityRequest(
type="post",
text="Batch activity 2",
user_id=self.test_user_id,
feeds=[self.test_feed.get_feed_identifier()],
),
]
response = self.client.feeds.upsert_activities(activities=activities)
Specify either the comment or the activity id
Reactions
For reactions specify the import in the following structure:
{
"reactions": [
{
"activity_id": "123",
"comment_id": "456",
"type": "like",
"user_id": "222",
"custom": {}
}
]
}
activities := []getstream.ActivityRequest{
{
Type: "post",
Text: getstream.PtrTo("Batch activity 1"),
UserID: &testUserID,
},
{
Type: "post",
Text: getstream.PtrTo("Batch activity 2"),
UserID: &testUserID,
},
}
response, err := feedsClient.UpsertActivities(ctx, &getstream.UpsertActivitiesRequest{
Activities: activities,
})
List<ActivityRequest> activities =
List.of(
ActivityRequest.builder()
.type("post")
.text("Batch activity 1")
.userID(testUserId)
.build(),
ActivityRequest.builder()
.type("post")
.text("Batch activity 2")
.userID(testUserId)
.build());
UpsertActivitiesRequest request =
UpsertActivitiesRequest.builder().activities(activities).build();
UpsertActivitiesResponse response = feeds.upsertActivities(request).execute().getData();
$activities = [
[
'type' => 'post',
'text' => 'Batch activity 1',
'user_id' => $this->testUserId,
],
[
'type' => 'post',
'text' => 'Batch activity 2',
'user_id' => $this->testUserId,
]
];
$response = $this->feedsV3Client->upsertActivities(
new GeneratedModels\UpsertActivitiesRequest(activities: $activities)
);
var activities = new List<ActivityRequest>
{
new ActivityRequest
{
Type = "post",
Text = "Batch activity 1",
UserID = _testUserId
},
new ActivityRequest
{
Type = "post",
Text = "Batch activity 2",
UserID = _testUserId
}
};
var response = await _feedsV3Client.UpsertActivitiesAsync(
new UpsertActivitiesRequest { Activities = activities }
);
activities = [
ActivityRequest(
type="post",
text="Batch activity 1",
user_id=self.test_user_id,
feeds=[self.test_feed.get_feed_identifier()],
),
ActivityRequest(
type="post",
text="Batch activity 2",
user_id=self.test_user_id,
feeds=[self.test_feed.get_feed_identifier()],
),
]
response = self.client.feeds.upsert_activities(activities=activities)
Specify either the comment or the activity id